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

Browser: improve 'bdd' import for bundlers #4769

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion browser-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,18 @@ Mocha.process = process;
/**
* Expose mocha.
*/

global.Mocha = Mocha;
global.mocha = mocha;

// for bundlers: enable `import {describe, it} from 'mocha'`
// `bdd` interface only
// prettier-ignore
[
'describe', 'context', 'it', 'specify',
'xdescribe', 'xcontext', 'xit', 'xspecify',
'before', 'beforeEach', 'afterEach', 'after'
].forEach(function(key) {
mocha[key] = global[key];
});

module.exports = mocha;
2 changes: 0 additions & 2 deletions test/browser-specific/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ global.expect = require('unexpected')
.use(require('unexpected-map'))
.use(require('unexpected-sinon'))
.use(require('unexpected-eventemitter'));

require('../../browser-entry');
11 changes: 11 additions & 0 deletions test/unit/required-tokens.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const assert = require('assert');
const {describe, it} = require('../..');

describe('using imported "describe"', function() {
it('using imported "it"', function(done) {
assert.ok(true);
done();
});
});