Search code examples
nightwatch.js

Mark the current test as skipped instead of failed


I have a test that goes through a process to get to the part that is the actual test. We have a situation where one of the setup steps/states may not be correct for executing the test. In that case I want to skip the current test, but not fail it. i.e. My list of quotes is empty, so I cannot click a quote to continue with the "Order a quote" process.

I don't want to fail the test, but I do need to make note that this test cannot be completed at this time.

Note that this is different than marking a module as @disabled or using the ''+ trick to skip an individual test. This is starting a test, determining the situation cannot be tested in the current state, and exiting the current test with a Skipped flag instead of a pass/fail.

(The issue stems from the state of the page being derived from 3rd party data that cannot be easily mocked. The quote MUST exist and be processable by the staging ERP to do the E2E testing...)


Solution

  • You could put the dependent test cases in the same test file and use skip_testcases_on_fail: true in your nightwatch configuration file

    In this case you would put the test that checks for the list of quotes first and the rest bellow it.

    module.exports = {
      'checkQuoteList case': function(browser) {
        ......
      },
    
      'clickQuote case': function(browser) {
        ........
      }
    };