Skip to content

Add timeout option to xits using arrow functions #3142

Closed

Description

Prerequisites

  • Checked that your issue isn't already filed by cross referencing issues with the common mistake label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
    node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha.

Description

When using the arrow function syntax to override the default timeout. You specifiy it on the return value of the it function.

it("should override the timeout", () => { }).timeout(100);

But if we want to ignore the test by adding an x we get an exception, which is annoying.

Steps to Reproduce

// Throws
xit("should override the timeout", () => { }).timeout(100);

Expected behavior: The test should be ignored

Actual behavior: We get an exception

Mocha` exploded!
TypeError: Cannot read property 'timeout' of undefined

Reproduces how often: 100%

Versions

mocha 4.0.1

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

Metadata

Assignees

No one assigned

    Labels

    type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions