英文:
Can't Run Beacause No Spec file found Cypress
问题
我正在使用 Cypress 版本 9.0.0,并在我的集成文件夹中创建了 Product1 和 Product2。我正在使用无头模式运行测试用例,使用以下命令 -
./node_modules/.bin/cypress run --spec cypress/integration/Product2/testcases/Login.spec.js
我的目录结构如下:
cypress/
fixture/
integration/
Product1/
testcases/
Login.spec.js
testlist ---> testlist 包含文件名,例如:Login.spec.js
usecases/
testlist ---> testlist 包含文件夹名,例如:testcases usecases
constant.js
Product2/
testcases/
Login.spec.js
testlist ---> testlist 包含文件名,例如:Login.spec.js
usecases/
testlist ---> testlist 包含文件夹名,例如:testcases usecases
constant.js
出现错误信息 -
找不到规范文件,无法运行
我们搜索匹配此通用模式的规范文件:
/root/temp/abc/UI/cypress/integration/Product2/testcases/Login.spec.js
但如果我使用 Product1,
命令
/root/temp/abc/UI/cypress/integration/Product1/testcases/Login.spec.js
它可以正常工作,测试用例可以成功运行。
我尝试了以下可能性,
- 在 cypress.json 中更改 "specPattern":"cypress/integration/**/*.js"
- 在集成中添加了包含 Product1 和 Product2 的 testlist
- 尝试 GitHub 讨论
- 使用
npx cypress run --config integrationFolder=cypress/integation/Product2/testcases/Login.spec.js
之后,所有 Product1 的测试用例都可以运行。
英文:
I am using Cypress version 9.0.0 and I have created Product1 and Product2 in my integration folder.I am using headless mode to run testcases using command -
./node_modules/.bin/cypress run --spec cypress/integration/Product2/testcases/Login.spec.js
my Directory structure is like:
cypress/
fixture/
integration/
Product1/
testcases/
Login.spec.js
testlist --->testlist contain fileName ex:Login.spec.js
usecases/
testlist ---->testlist contain folderName ex:testcases usecases
constant.js
Product2/
testcases/
Login.spec.js
testlist ---->testlist contain fileName ex:Login.spec.js
usecases/
testlist ---->testlist contain folderName ex:testcases usecases
constant.js
getting error as-
Can't run because no spec files were found
We searched for specs matching this glob pattern:
>/root/temp/abc/UI/cypress/integration/Product2/testcases/Login.spec.js
but if i used for Product1 ,
command
>/root/temp/abc/UI/cypress/integration/Product1/testcases/Login.spec.js
it Works fine and testcase run successfully.
I have Tried possibilities,
- Changed in "specPattern":"cypress/integration/**/*.js" in cypress.json
- Added testlist in integration which contain Product1 Product2
- Tried github Discussion
- used
npx cypress run --config integrationFolder=cypress/integation/Product2/testcases/Login.spec.js
after this,all testcases run for Product1
答案1
得分: 2
The Product1 and Product2 folders are shown at the same level as cypress/integration
, so you can't get to them with specPattern: 'cypress/integration/**/*.js'
- that will preclude those folder.
If you made a mistake in the folder diagram, then your simplest option is to change specPattern
to an array
{
...
specPattern: [
'cypress/integration/**/*.js', // entry for specs under integration
'**/Product1/**/*.js', // specs under Product1
'**/Product2/**/*.js', // specs under Product2
]
}
英文:
The Product1 and Product2 folders are shown at the same level as cypress/integration
, so you can't get to them with specPattern: 'cypress/integration/**/*.js'
- that will preclude those folder.
If you made a mistake in the folder diagram, then your simplest option is to change specPattern
to an array
{
...
specPattern: [
'cypress/integration/**/*.js', // entry for specs under integration
'**/Product1/**/*.js', // specs under Product1
'**/Product2/**/*.js', // specs under Product2
]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论