diff --git a/browser-entry.js b/browser-entry.js index 9719c3d528..7f1dd99689 100644 --- a/browser-entry.js +++ b/browser-entry.js @@ -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; diff --git a/test/browser-specific/setup.js b/test/browser-specific/setup.js index 2c9b490b2d..611346665a 100644 --- a/test/browser-specific/setup.js +++ b/test/browser-specific/setup.js @@ -8,5 +8,3 @@ global.expect = require('unexpected') .use(require('unexpected-map')) .use(require('unexpected-sinon')) .use(require('unexpected-eventemitter')); - -require('../../browser-entry'); diff --git a/test/unit/required-tokens.spec.js b/test/unit/required-tokens.spec.js new file mode 100644 index 0000000000..bb9f05f44e --- /dev/null +++ b/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(); + }); +});