From 8421974e8d252e2ef11602d15bed178e4f5f4534 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=8E?= <1395348685z@gmail.com>
Date: Fri, 17 Sep 2021 20:26:17 +0800
Subject: [PATCH] fix(browser): stop using all global vars in 'browser-entry'
 (#4746)

---
 browser-entry.js                  |  5 +----
 lib/cli/watch-run.js              |  4 ++--
 test/browser-specific/setup.js    |  2 ++
 test/unit/required-tokens.spec.js | 12 ------------
 4 files changed, 5 insertions(+), 18 deletions(-)
 delete mode 100644 test/unit/required-tokens.spec.js

diff --git a/browser-entry.js b/browser-entry.js
index dee3789231..9719c3d528 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 dabcd535fb..93f5059f1c 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 611346665a..2c9b490b2d 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 9b6f88433f..0000000000
--- 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();
-  });
-});