javascript - Cypress :只运行一项测试

标签 javascript automated-tests cypress e2e-testing

我只想切换运行一项测试,因此我不必等待其他测试才能看到一项测试的结果。

目前,我注释掉了我的其他测试,但这真的很烦人。

有没有办法在 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!


在一个文件中只运行一个测试
您可以使用 .onlythe 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:
enter image description here

关于javascript - Cypress :只运行一项测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55054337/

相关文章:

javascript - 初学者 Javascript 数组下拉列表

Javascript 'THIS' 值使用构造函数而不分配给变量

cypress - 自定义事件和 cy.get

无法识别 Cypress 自定义命令

testing - 在 Cypress 中选择 Kendo ComboBox

php - PHP 邮件中的动态文本框

javascript - mocha - 执行测试前等待一分钟

asp.net-mvc-4 - 使用 Specflow 为 Mvc4/WebApi 网站编写验收测试

python - 有没有办法配置 Robot Framework,这样执行就不会因失败而停止

ios - 如何在 Xcode 中执行数据驱动测试