Skip to content

Commit 012d79d

Browse files
authoredOct 15, 2021
fix(browser): enable 'bdd' import for bundlers (#4769)
1 parent 111467f commit 012d79d

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed
 

‎browser-entry.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,18 @@ Mocha.process = process;
209209
/**
210210
* Expose mocha.
211211
*/
212-
213212
global.Mocha = Mocha;
214213
global.mocha = mocha;
215214

215+
// for bundlers: enable `import {describe, it} from 'mocha'`
216+
// `bdd` interface only
217+
// prettier-ignore
218+
[
219+
'describe', 'context', 'it', 'specify',
220+
'xdescribe', 'xcontext', 'xit', 'xspecify',
221+
'before', 'beforeEach', 'afterEach', 'after'
222+
].forEach(function(key) {
223+
mocha[key] = global[key];
224+
});
225+
216226
module.exports = mocha;

‎test/browser-specific/setup.js

-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ global.expect = require('unexpected')
88
.use(require('unexpected-map'))
99
.use(require('unexpected-sinon'))
1010
.use(require('unexpected-eventemitter'));
11-
12-
require('../../browser-entry');

‎test/unit/required-tokens.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
const {describe, it} = require('../..');
5+
6+
describe('using imported "describe"', function() {
7+
it('using imported "it"', function(done) {
8+
assert.ok(true);
9+
done();
10+
});
11+
});

0 commit comments

Comments
 (0)
Please sign in to comment.