赛普拉斯:仅运行一项测试 [英] Cypress: run only one test
问题描述
我只想切换运行一个测试,所以我不必等待其他测试才能看到一个测试的结果。
I want to toggle only running one test, so I don't have to wait for my other tests to see the result of one test.
当前,我注释掉我的其他测试,但这确实很烦人。
Currently, I comment out my other tests, but this is really annoying.
是否有一种方法可以切换仅在Cypress中运行一个测试 c>?
Is there a way to toggle only running one test in Cypress
?
推荐答案
只运行一个文件
to run only one file
cypress run --spec path/to/file.spec.js
或使用全局模式:
cypress run --spec 'path/to/files/*.spec.js'
注意:您需要将您的glob模式用单引号引起来,以避免shell扩展!
Note: you need to wrap your glob patterns in single quotes to avoid shell expansion!
只在其中运行一个测试文件
您可以使用 .only
。 cypress.io/指南/核心概念/写作与组织-tests.html#Exclusion-and-Inclusion-Tests rel = noreferrer>赛普拉斯文档
to run only one test in a file
You can use a .only
as described in the Cypress docs
it.only('only run this one', () => {
// similarly use it.skip(...) to skip a test
})
it('not this one', () => {
})
此外,您也可以使用 describe
和上下文
块
Also, you can do the same with describe
and context
blocks
还有一个不错的 VSCode
扩展名,可以添加/删除。仅
使用键盘快捷键就更容易了。称为Test Utils(可与js,咖啡和打字稿一起使用):
there's also a nice VSCode
extension to make adding/removing .only
's easier with keyboard shortcuts. It's called Test Utils (works with js, coffee, and typescript):
这篇关于赛普拉斯:仅运行一项测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!