From 552c20879853e3339812c58632ec7558f6f1c40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E?= <1395348685z@gmail.com> Date: Sun, 12 Sep 2021 22:43:18 +0800 Subject: [PATCH] fix(browser): stop using all global vars when init --- browser-entry.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/browser-entry.js b/browser-entry.js index dee3789231..cb59ecc39d 100644 --- a/browser-entry.js +++ b/browser-entry.js @@ -216,4 +216,29 @@ 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); +[ + 'Mocha', + 'after', + 'afterEach', + 'before', + 'beforeEach', + 'context', + 'describe', + 'it', + 'mocha', + 'run', + 'setup', + 'specify', + 'suite', + 'suiteSetup', + 'suiteTeardown', + 'teardown', + 'test', + 'xcontext', + 'xdescribe', + 'xit', + 'xspecify' +].forEach(function(key) { + if (key in global) mocha[key] = global[key]; +}); +module.exports = mocha;