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 #2972

Closed
LukasBombach opened this issue Aug 28, 2017 · 6 comments
Closed

import / require xit #2972

LukasBombach opened this issue Aug 28, 2017 · 6 comments
Labels
status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer

Comments

@LukasBombach
Copy link

Is there a way to import / require to satisfy my tooling?

I can do

import { it } from 'mocha';

but not

import { xit } from 'mocha';

or

import { xit } from 'mocha/lib/interfaces/bdd';
@ScottFreeCode
Copy link
Contributor

Looks like the x cases are missing from

mocha/lib/mocha.js

Lines 200 to 214 in 2bc9c4d

this.suite.on('pre-require', function (context) {
exports.afterEach = context.afterEach || context.teardown;
exports.after = context.after || context.suiteTeardown;
exports.beforeEach = context.beforeEach || context.setup;
exports.before = context.before || context.suiteSetup;
exports.describe = context.describe || context.suite;
exports.it = context.it || context.test;
exports.setup = context.setup || context.beforeEach;
exports.suiteSetup = context.suiteSetup || context.before;
exports.suiteTeardown = context.suiteTeardown || context.after;
exports.suite = context.suite || context.describe;
exports.teardown = context.teardown || context.afterEach;
exports.test = context.test || context.it;
exports.run = context.run;
});
They should be pretty easy to add, although I'll have to look around a bit more to find where we have tests for those exports so we can add tests for the x cases.

@ScottFreeCode ScottFreeCode added type: bug a defect, confirmed by a maintainer confirmed status: accepting prs Mocha can use your help with this one! labels Aug 31, 2017
@solodynamo
Copy link
Contributor

Hey @ScottFreeCode I would like to give a try to this.

@ScottFreeCode
Copy link
Contributor

We'd be happy to take a pull request!

Don't worry about including tests at this point -- I just went looking for them and it seems that we're currently only testing describe and it out of all those functions: https://github.com/mochajs/mocha/blob/f20de56637b2223f614ce40adc0d41a58030f042/test/unit/required-tokens.spec.js So we'll want to expand that, but not just for the couple of new additions, and can/should do it in a separate PR.

@ScottFreeCode
Copy link
Contributor

(Created #2982 for adding a more complete test of this feature.)

solodynamo added a commit to solodynamo/mocha that referenced this issue Sep 9, 2017
@solodynamo
Copy link
Contributor

solodynamo commented Sep 9, 2017

Hey @ScottFreeCode made a PR for this issue #2997. Please merge if all looks fine.

@rpaterson
Copy link

I think this fix introduced a bug #3004

sgilroy pushed a commit to TwineHealth/mocha that referenced this issue Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants