Skip to content

Detect test failures from test code?

Closed

Description

Is there a way to detect if any test has failed from within test code?

describe('some tests', function () {
  /*
   * Run some tests...
   */
})

after(function () {
  failures = ? // <--- what goes here?
  console.log(failures + " tests failed!")
})

I'd use this to keep chromedriver's browser open if a test failed, and to report success or failure to sauce labs after tests run. I could see pulling saucelabs reporting out into a reporter using multiple reporters #930, but keeping chromedriver open makes most sense in test code, where we launch the browser.

Runner and Reporters have the info I'm looking for as stats but I'm not sure how to get to them from within a test file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions