In Cypress.io is there anyway to control the test run?

 ̄綄美尐妖づ 提交于 2019-12-12 11:23:32

问题


My 'example-spec.js' tests under the integration folder contain 15 tests, each time the Cypress.io will run all the 15 tests written in the 'example-spec.js'. I would like to choose and specify 'which' test needs to run, maybe 1 or 2 test at a time. The reason maybe I don't want to wait to see the output of all test while adding a 'new' test. Is there any way to control the test run in Cypress.io?


回答1:


I don't know if there's way to do it from user interface, but You can use mocha methods to run only chosen tests by:

  1. Replacing it with xit tests you want to omit
  2. Using it.skip on tests you want to omit
  3. Using it.only on single test you want to run



回答2:


Use it.only() and it.skip()

See cypress documentation: https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Excluding-and-Including-Tests




回答3:


I just tried this it.skip and that didn't work for me.

But using this.skip(); is working a lot better.

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/')
})


来源:https://stackoverflow.com/questions/51850851/in-cypress-io-is-there-anyway-to-control-the-test-run

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!