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

import/require xit, fixes #2972 #2997

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/mocha.js
Expand Up @@ -204,6 +204,7 @@ Mocha.prototype.ui = function (name) {
exports.before = context.before || context.suiteSetup;
exports.describe = context.describe || context.suite;
exports.it = context.it || context.test;
exports.xit = context.xit || context.test;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is the only change that should be needed to merge this. Any others suggested are optional.)

So, the context.test on the right side of the || isn't right, that's the same as for the non-skipped it. (With that said, you can skip to the very bottom for recommended fix; the rest here is explanation.) I'm not 100% certain whether this involves the QUnit interface at all, but it seems these are basically enabling require-based used of either the BDD or the TDD interface when either the BDD or TDD interface is used; so, the || here would be to replicate the BDD interface in the event the TDD interface is chosen. So, I double-checked what the TDD interface does for skipping.

In the BDD interface, xit, xspecify and it.skip are all set to a function that just calls it while only using the title. In the TDD interface, there are no x functions, and test.skip delegates to the "common interface" test.skip, which in turn relies on the TDD interface's test function and -- like the BDD function -- just passes it only the title. (Weird coupling between the "common interface" and the TDD interface... but nothing worth worrying about here.)

So it looks like it should be perfectly safe to change this to || context.test.skip.

exports.setup = context.setup || context.beforeEach;
exports.suiteSetup = context.suiteSetup || context.before;
exports.suiteTeardown = context.suiteTeardown || context.after;
Expand Down
1 change: 1 addition & 0 deletions mocha.js
Expand Up @@ -1464,6 +1464,7 @@ Mocha.prototype.ui = function (name) {
exports.before = context.before || context.suiteSetup;
exports.describe = context.describe || context.suite;
exports.it = context.it || context.test;
exports.xit = context.xit || context.test;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tip: you don't actually have to update the mocha.js file at the base of the project, as it is generated from the other files as part of the publication process. (On the other hand, for the same reason, you don't have to not update it either -- it will simply be overwritten later, as long as you update the other files in addition. I just mention this because it's useful to know you don't have search through the gigantic bundle for the code to update and do have to update other files for changes to actually be picked up.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ScottFreeCode Updated the PR with suggested changes. This time not updated mocha.js at root level.

exports.setup = context.setup || context.beforeEach;
exports.suiteSetup = context.suiteSetup || context.before;
exports.suiteTeardown = context.suiteTeardown || context.after;
Expand Down