在Cypress.io中是否有控制测试运行的方法?
In Cypress.io is there anyway to control the test run?
我在集成文件夹下的'example-spec.js'测试包含15个测试,每次Cypress.io将运行写在'example-spec.js'中的所有15个测试。我想选择并指定 'which' 测试需要 运行,一次可能进行 1 或 2 次测试。原因可能是我不想在添加 'new' 测试时等待查看所有测试的输出。 Cypress.io中的测试运行有什么办法可以控制吗?
我不知道是否有办法从用户界面做到这一点,但您可以使用 mocha 方法 运行 只选择测试:
- 将
it
替换为 xit
您要忽略的测试
- 对要省略的测试使用
it.skip
- 在您想要 运行
的单个测试中使用 it.only
要跳过整个 context/describe 套件,请使用相同的 context.skip()
或 describe.skip()
。
使用it.only()
和it.skip()
我刚试过这个 it.skip
但对我不起作用。
但是使用 this.skip();
效果更好。
it('test page', function () {
// skip this test for now
this.skip();
cy.visit('http://example.com/')
cy.contains('test page').click()
cy.url()
.should('include', '/test-page/')
})
我在集成文件夹下的'example-spec.js'测试包含15个测试,每次Cypress.io将运行写在'example-spec.js'中的所有15个测试。我想选择并指定 'which' 测试需要 运行,一次可能进行 1 或 2 次测试。原因可能是我不想在添加 'new' 测试时等待查看所有测试的输出。 Cypress.io中的测试运行有什么办法可以控制吗?
我不知道是否有办法从用户界面做到这一点,但您可以使用 mocha 方法 运行 只选择测试:
- 将
it
替换为xit
您要忽略的测试 - 对要省略的测试使用
it.skip
- 在您想要 运行 的单个测试中使用
it.only
要跳过整个 context/describe 套件,请使用相同的 context.skip()
或 describe.skip()
。
使用it.only()
和it.skip()
我刚试过这个 it.skip
但对我不起作用。
但是使用 this.skip();
效果更好。
it('test page', function () {
// skip this test for now
this.skip();
cy.visit('http://example.com/')
cy.contains('test page').click()
cy.url()
.should('include', '/test-page/')
})