Cypress:是否将测试从多个NPM依赖项导入到&Quot;。/Cypress/集成&Quot;? [英] Cypress: Import tests into "./cypress/integration" from multiple npm dependencies?
本文介绍了Cypress:是否将测试从多个NPM依赖项导入到&Quot;。/Cypress/集成&Quot;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个非常大的基于Cypress的测试套件cy_tests_A_B_monolith
,./cypress/integration
文件夹中的测试数量很多。
我希望将这些集成测试划分到它们自己的NPM模块中,并使它们依赖于更易于管理的Cypress测试套件。
- 来自
cy_tests_A_B_monolith
- 至
cy_tests_A_B_manageable
+依赖项cy_test_A
+cy_test_B
草稿如下。不确定如何将./cypress/integration/***
测试导入到另一个Cypress测试套件中作为依赖项。
非常感谢您的建议,谢谢。
草稿:
来自整体
多个集成测试+src自定义命令...
NPMcy_tests_A_B_monolith
├── cypress
│ ├── integration
│ │ ├── A
│ │ └── B
│ └── support
│ └── specs
│ ├── A
│ └── B
├── src
│ ├── A
│ | └── commands
│ └── B
│ └── commands
至...
通过维护整体测试套件的子集/Cypress/集成,将整体测试套件划分为可管理的测试套件
NPMcy_tests_A_B_manageable
├── cypress
│ ├── integration
│ │ ├── A << dependency imported cy_test_A ./cypress/integration/A
│ │ └── B << dependency imported cy_test_B ./cypress/integration/B
NPMcy_test_A
├── cypress
│ ├── integration
│ │ └── A
│ └── support
│ └── specs
│ └── A
├── src
│ └── A
│ └── commands
NPMcy_test_B
├── cypress
│ ├── integration
│ │ └── B
│ └── support
│ └── specs
│ └── B
├── src
│ └── B
│ └── commands
推荐答案
有点时髦,但您可以使用cy_tests_A_B_manageable
中的Module API来驱动来自其他项目的测试
/scripts/run-cypress.js
const cypress = require('cypress')
const testProjects = ['../cy_test_A', '../cy_test_B']
testProjects.forEach(project => {
cypress.run({
reporter: 'junit',
browser: 'chrome',
project, // can specify the project root here
config: {
video: false,
},
env: {
login_url: '/login',
products_url: '/products',
},
})
})
与cypress open
一起打开多个跑道,不理想...
但可以通过此文件夹设置使用cypress.open(...)
cypress-multi-project
- cy_test_A
- cy_test_B
- cypress-run-other-project
cypress-multi-project/cypress.json
{
"integrationFolder": "./",
"testFiles": "**/*.spec.js" // must uniquely suffix integration tests
}
cypress-multi-project/cypress-run-other-project/scripts/run-cypress.js
const cypress = require('cypress')
cypress.open({
reporter: 'junit',
browser: 'chrome',
project: '..', // project is parent folder
config: {
video: true,
},
env: {
login_url: '/login',
products_url: '/products',
},
})
这篇关于Cypress:是否将测试从多个NPM依赖项导入到&Quot;。/Cypress/集成&Quot;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文