Skip to content

Commit

Permalink
fix(browser): enable 'bdd' import for bundlers (mochajs#4769)
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba authored and KuznetsovRoman committed Sep 6, 2022
1 parent 5ba2616 commit 6108234
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 11 additions & 1 deletion browser-entry.js
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
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
@@ -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();
});
});

0 comments on commit 6108234

Please sign in to comment.