我只想切换运行一项测试,因此我不必等待其他测试才能看到一项测试的结果。
目前,我注释掉了我的其他测试,但这真的很烦人。
有没有办法在 Cypress
中切换只运行一个测试? ?
最佳答案
只运行一个文件
cypress run --spec path/to/file.spec.js
或使用全局模式:cypress run --spec 'path/to/files/*.spec.js'
Note: you need to wrap your glob patterns in single quotes to avoid shell expansion!
在一个文件中只运行一个测试
您可以使用
.only
如 the Cypress docs 中所述it.only('only run this one', () => {
// similarly use it.skip(...) to skip a test
})
it('not this one', () => {
})
此外,您可以对 describe
执行相同操作和 context
block 编辑:
还有一个不错的
VSCode
进行添加/删除的扩展 .only
使用键盘快捷键更容易。它被称为 Test Utils(使用 ext install chrisbreiding.test-utils
安装)。它适用于 js、coffee 和 typescript:关于javascript - Cypress :只运行一项测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55054337/