Skip to content
/ jest Public
forked from jestjs/jest

Commit

Permalink
don't use Symbol for our promise
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 20, 2018
1 parent 493f7ee commit 48da087
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/jest-util/src/install_common_globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export default function(globalObject: Global, globals: ConfigGlobals) {
globalObject.process = createProcessObject();

// Keep a reference to "Promise", since "jasmine_light.js" needs it.
globalObject[globalObject.Symbol.for('jest-native-promise')] = Promise;
Object.defineProperty(globalObject, 'jest-promise-stay-away', {
configurable: false,
enumerable: false,
value: Promise,
writable: false,
});

// Forward some APIs.
DTRACE.forEach(dtrace => {
Expand Down
3 changes: 1 addition & 2 deletions scripts/babel-plugin-jest-native-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
// This plugin exists to make sure that we use a `Promise` that has not been messed with by user code.
// Might consider extending this to other globals as well in the future

const jestPromise =
"(global[Symbol.for('jest-native-promise')] || global.Promise)";
const jestPromise = "(global['jest-promise-stay-away'] || global.Promise)";

module.exports = () => ({
name: 'jest-native-promise',
Expand Down

0 comments on commit 48da087

Please sign in to comment.