Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to explicitly fail test in hook callback #1039

Closed
eheikes opened this issue Jun 27, 2016 · 0 comments
Closed

Unable to explicitly fail test in hook callback #1039

eheikes opened this issue Jun 27, 2016 · 0 comments
Assignees
Labels

Comments

@eheikes
Copy link

eheikes commented Jun 27, 2016

The docs state:

Failing the test intentionally in a test hook is achievable by simply calling done with an Error argument: ...

However, I can't seem to get it working:

module.exports = {
  beforeEach: function(browser) {
    browser
      .url('http://www.google.com')
      .waitForElementPresent('body', 1000);
  },
  afterEach: function(browser, done) {
    done(new Error('explicitly throw an error'));
  },
  'example test': function(browser) {
    browser
      .setValue('input[type="text"]', 'nightwatch')
      .submitForm('form')
      .pause(1000)
      .assert.elementPresent('#search')
      .end();
  }
};

Nightwatch doesn't output any errors, and the nightwatch script ends with a 0 error code. I tried it in an after hook as well, with no luck.

(Nightwatch v0.9.5, Node v5.11.1, Mac OS 10.11.5, Selenium v2.53.0, ChromeDriver 2.21.371459)

@beatfactor beatfactor added the bug label Jun 28, 2016
@beatfactor beatfactor self-assigned this Aug 5, 2016
ianwsperber added a commit to ianwsperber/nightwatch that referenced this issue Mar 22, 2017
ianwsperber added a commit to ianwsperber/nightwatch that referenced this issue Mar 22, 2017
ianwsperber added a commit to ianwsperber/nightwatch that referenced this issue Mar 22, 2017
ianwsperber added a commit to ianwsperber/nightwatch that referenced this issue Mar 22, 2017
Provide error tests for after, before and beforeEach all fail
ianwsperber added a commit to ianwsperber/nightwatch that referenced this issue Mar 22, 2017
ianwsperber added a commit to ianwsperber/nightwatch that referenced this issue Mar 22, 2017
ianwsperber added a commit to ianwsperber/nightwatch that referenced this issue Mar 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants