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

Add timeout option to xits using arrow functions #3142

Closed
4 tasks done
MattOakley opened this issue Dec 11, 2017 · 5 comments · Fixed by #3143
Closed
4 tasks done

Add timeout option to xits using arrow functions #3142

MattOakley opened this issue Dec 11, 2017 · 5 comments · Fixed by #3143
Labels
type: bug a defect, confirmed by a maintainer

Comments

@MattOakley
Copy link

MattOakley commented Dec 11, 2017

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

@boneskull
Copy link
Member

Is this a documented API? I don't recall ever seeing anyone use this before.

@boneskull boneskull added the type: bug a defect, confirmed by a maintainer label Dec 11, 2017
@boneskull
Copy link
Member

anyway, this looks pretty trivial to address. I'm going to call it a bug even though it's more of an "internal consistency" issue, since we don't necessarily expect consumers to use the object returned from it or xit for anything.

@Bamieh
Copy link
Contributor

Bamieh commented Dec 11, 2017

@boneskull this is a very interesting side effect of returning the test object from inside the it function. I have a PR coming in a few.

Bamieh added a commit that referenced this issue Dec 11, 2017
@boneskull
Copy link
Member

@Bamieh I've already got one ready ;)

@boneskull
Copy link
Member

@Bamieh beat me to it

boneskull pushed a commit that referenced this issue Dec 12, 2017
* Fixes #3142

* added test cases suggested by @boneskull

* fixed miswording

* attempt to fix bizarre AppVeyor problem by way of npm upgrade
OmgImAlexis pushed a commit to agenda/agenda that referenced this issue Jun 26, 2018
This Pull Request updates dependency [mocha](https://github.com/mochajs/mocha) from `v4.0.1` to `v4.1.0`



<details>
<summary>Release Notes</summary>

### [`v4.1.0`](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#&#8203;410--2017-12-28)
[Compare Source](mochajs/mocha@v4.0.1...v4.1.0)
This is mainly a "housekeeping" release.

Welcome [@&#8203;Bamieh] and [@&#8203;xxczaki] to the team!
#### 🐛 Fixes

- [#&#8203;2661]: `progress` reporter now accepts reporter options ([@&#8203;canoztokmak])
- [#&#8203;3142]: `xit` in `bdd` interface now properly returns its `Test` object ([@&#8203;Bamieh])
- [#&#8203;3075]: Diffs now computed eagerly to avoid misinformation when reported ([@&#8203;abrady0])
- [#&#8203;2745]: `--help` will now help you even if you have a `mocha.opts` ([@&#8203;Zarel])
#### 🎉 Enhancements

- [#&#8203;2514]: The `--no-diff` flag will completely disable diff output ([@&#8203;CapacitorSet])
- [#&#8203;3058]: All "setters" in Mocha's API are now also "getters" if called without arguments ([@&#8203;makepanic])
#### 📖 Documentation

- [#&#8203;3170]: Optimization and site speed improvements ([@&#8203;Munter])
- [#&#8203;2987]: Moved the old [site repo](https://github.com/mochajs/mochajs.github.io) into the main repo under `docs/` ([@&#8203;boneskull])
- [#&#8203;2896]: Add [maintainer guide](https://github.com/mochajs/mocha/blob/master/MAINTAINERS.md) ([@&#8203;boneskull])
- Various fixes and updates ([@&#8203;xxczaki], [@&#8203;maty21], [@&#8203;leedm777])
#### 🔩 Other

- Test improvements and fixes ([@&#8203;eugenet8k], [@&#8203;ngeor], [@&#8203;38elements], [@&#8203;Gerhut], [@&#8203;ScottFreeCode], [@&#8203;boneskull])
- Refactoring and cruft excision ([@&#8203;38elements], [@&#8203;Bamieh], [@&#8203;finnigantime], [@&#8203;boneskull])

[#&#8203;2661]: `mochajs/mocha#2661
[#&#8203;3142]: `mochajs/mocha#3142
[#&#8203;3075]: `mochajs/mocha#3075
[#&#8203;2745]: `mochajs/mocha#2745
[#&#8203;2514]: `mochajs/mocha#2514
[#&#8203;3058]: `mochajs/mocha#3058
[#&#8203;3170]: `mochajs/mocha#3170
[#&#8203;2987]: `mochajs/mocha#2987
[#&#8203;2896]: `mochajs/mocha#2896
[@&#8203;canoztokmak]: https://github.com/canoztokmak
[@&#8203;Bamieh]: https://github.com/Bamieh
[@&#8203;abrady0]: https://github.com/abrady0
[@&#8203;Zarel]: https://github.com/Zarel
[@&#8203;CapacitorSet]: https://github.com/CapacitorSet
[@&#8203;xxczaki]: https://github.com/xxczaki
[@&#8203;maty21]: https://github.com/maty21
[@&#8203;leedm777]: https://github.com/leedm777
[@&#8203;eugenet8k]: https://github.com/eugenet8k
[@&#8203;38elements]: https://github.com/38elements
[@&#8203;Gerhut]: https://github.com/Gerhut
[@&#8203;finnigantime]: https://github.com/finnigantime

---

</details>




---

This PR has been generated by [Renovate Bot](https://renovatebot.com).
sgilroy pushed a commit to TwineHealth/mocha that referenced this issue Feb 27, 2019
… (mochajs#3143)

* Fixes mochajs#3142

* added test cases suggested by @boneskull

* fixed miswording

* attempt to fix bizarre AppVeyor problem by way of npm upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants