Logan Smyth 6fa6f5924d [7.0] Run Babel's unittests in a custom sandbox (take 2). (#5263)
* Run Babel's unittests in a custom sandbox (take 2).

* Add tests for sandboxing behavior.
2017-02-04 13:31:33 -08:00

25 lines
604 B
JavaScript

import assert from "assert";
import { runCodeInTestContext } from "..";
describe("helper-transform-fixture-test-runner", function() {
it("should not execute code in Node's global context", function() {
try {
global.foo = "outer";
runCodeInTestContext(`
assert.equal(global.foo, undefined);
global.foo = "inner";
`);
assert.equal(global.foo, "outer");
runCodeInTestContext(`
assert.equal(global.foo, "inner");
`);
} finally {
delete global.foo;
runCodeInTestContext(`
delete global.foo;
`);
}
});
});