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

🛠️ Repo: Test "require interface" #2982

Open
ScottFreeCode opened this issue Sep 4, 2017 · 1 comment
Open

🛠️ Repo: Test "require interface" #2982

ScottFreeCode opened this issue Sep 4, 2017 · 1 comment
Labels
area: repository tooling concerning ease of contribution semver-patch implementation requires increase of "patch" version number; "bug fixes" status: accepting prs Mocha can use your help with this one!

Comments

@ScottFreeCode
Copy link
Contributor

We're currently testing the ability to require("mocha").it and require("mocha").describe but none of the other exported interface functions: https://github.com/mochajs/mocha/blob/f20de56637b2223f614ce40adc0d41a58030f042/test/unit/required-tokens.spec.js

Full list here:

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;
});

I think the test file above should just use the global describe and it, but inside the it we should assert that the exports all are equal to the corresponding globals. It would be "more brittle" in the sense that we would have to change the test if we wanted to change the implementation from a simple reference copy to having separate global and exported functions, but I have a hard time imagining why we'd want/need to do that at the moment, and equality comparison would be fine for the current implementation and waaaaay easier than coming up with a way to use every last one of them and check for the correct behavior (and the current test doesn't even do the correct-behavior part for the two functions it does try using).

While we're in there, let's remove the done since the test is (and would still be) synchronous.

Note that once #2972 is resolved we should include xit (and whatever other x functions we have) in the new test.

@ScottFreeCode
Copy link
Contributor Author

#3004 should have been caught by some kind of test. Can we combine the concept of the JSAPI tests with the concept of the specific interfaces' tests?

@ScottFreeCode ScottFreeCode self-assigned this Sep 29, 2017
@boneskull boneskull added the semver-patch implementation requires increase of "patch" version number; "bug fixes" label Oct 4, 2017
@JoshuaKGoldberg JoshuaKGoldberg changed the title test "require interface" 🛠️ Repo: test "require interface" Dec 27, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title 🛠️ Repo: test "require interface" 🛠️ Repo: Test "require interface" Dec 27, 2023
@JoshuaKGoldberg JoshuaKGoldberg added area: repository tooling concerning ease of contribution and removed area: qa labels Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: repository tooling concerning ease of contribution semver-patch implementation requires increase of "patch" version number; "bug fixes" status: accepting prs Mocha can use your help with this one!
Projects
None yet
Development

No branches or pull requests

3 participants