-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
delete global.someProp
doesn't work.
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install
and yarn test
.
Repl.it - https://repl.it/GXd3
const assert = require('assert');
describe('removing stuff from the global object', () => {
describe(`via 'delete global.prop'`, () => {
it('should set the value to undefined', () => {
global.someValue = 'asdf';
assert.equal(global.someValue, 'asdf');
delete global.someValue;
assert.equal(global.someValue, undefined);
});
});
describe(`via 'global.prop = undefined;'`, () => {
it('should set the value to undefined', () => {
global.someValue2 = 'asdf';
assert.equal(global.someValue2, 'asdf');
global.someValue2 = undefined;
assert.equal(global.someValue2, undefined);
});
});
});
What is the expected behavior?
delete global.someProp
should make global.someProp === undefined
true.
This works in mocha, jasmine, plain old node, and I think it works when running via vm
. We're investigating a move to Jest, but are running into some subtle issues related to this.
For example this function in enzyme doesn't behave correctly - https://github.com/airbnb/enzyme/blob/master/src/Utils.js#L213
We could attempt to work around this, but I feel like this will repeatedly come up in our codebase and will lead to lots of wasted time.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
node - v4.6.2
npm - 2.15.11
jest - v19.0.0
os - OSX Sierra v10.12.1