我想切换为只运行一个测试,这样就不必等待其他测试才能看到一个测试的结果。
目前,我注释掉了其他测试,但这真的很烦人。
有没有办法切换到只运行一个测试在Cypress?
我想切换为只运行一个测试,这样就不必等待其他测试才能看到一个测试的结果。
目前,我注释掉了其他测试,但这真的很烦人。
有没有办法切换到只运行一个测试在Cypress?
当前回答
最著名的解决方案已经存在,只需要在控制台中添加一个简单的参数。 https://github.com/cypress-io/cypress/tree/develop/npm/grep
简单地运行: npx cypress run——env grep="TestName"——spec "filename"
Cypress .only()函数仅用于开发。
其他回答
我的测试文件有一个类似于/something.test的结构。并命令NPX cypress run——spec path/something.test。JSX在终端中给出了以下异常:
Can't run because no spec files were found.
We searched for any files matching this glob pattern:
...
令人惊讶的是,下面的工作和运行测试正好为一个文件(提供你已经安装了jest):
jest path/something.test.jsx
您可以像这样运行测试。
运行——spec **/file.js
只为你想要执行的测试设置.,然后以NPX cypress run——spec path/to/your-file.spec.js的形式运行spec
在使用cypress open执行测试脚本时,使用@focus关键字
你可以用这个
cypress run -- --spec 'path/to/files/*.spec.js'
or
npm run --spec 'path/to/files/*.spec.js'
这对我很管用。
非常感谢