Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

fix(browser): stop using all global vars in 'browser-entry' (#4746)

华8421974e8d25
diff --git a/browser-entry.js b/browser-entry.js
index dee37892..9719c3d5 100644
--- a/browser-entry.js
+++ b/browser-entry.js
@@ -213,7 +213,4 @@ Mocha.process = process;
global.Mocha = Mocha;
global.mocha = mocha;
-// this allows test/acceptance/required-tokens.js to pass; thus,
-// you can now do `const describe = require('mocha').describe` in a
-// browser context (assuming browserification). should fix #880
-module.exports = Object.assign(mocha, global);
+module.exports = mocha;
diff --git a/lib/cli/watch-run.js b/lib/cli/watch-run.js
index dabcd535..93f5059f 100644
--- a/lib/cli/watch-run.js
+++ b/lib/cli/watch-run.js
@@ -46,7 +46,7 @@ exports.watchParallelRun = (
// this `require` is needed because the require cache has been cleared. the dynamic
// exports set via the below call to `mocha.ui()` won't work properly if a
- // test depends on this module (see `required-tokens.spec.js`).
+ // test depends on this module.
const Mocha = require('../mocha');
// ... and now that we've gotten a new module, we need to use it again due
@@ -108,7 +108,7 @@ exports.watchRun = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => {
// this `require` is needed because the require cache has been cleared. the dynamic
// exports set via the below call to `mocha.ui()` won't work properly if a
- // test depends on this module (see `required-tokens.spec.js`).
+ // test depends on this module.
const Mocha = require('../mocha');
// ... and now that we've gotten a new module, we need to use it again due
diff --git a/test/browser-specific/setup.js b/test/browser-specific/setup.js
index 61134666..2c9b490b 100644
--- a/test/browser-specific/setup.js
+++ b/test/browser-specific/setup.js
@@ -8,3 +8,5 @@ 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
deleted file mode 100644
index 9b6f8843..00000000
--- a/test/unit/required-tokens.spec.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict';
-
-var assert = require('assert');
-var describe = require('../..').describe;
-var it = require('../..').it;
-
-describe('using imported describe', function() {
- it('using imported it', function(done) {
- assert.ok(true);
- done();
- });
-});