Update chai to 4.x (#6002)
This commit is contained in:
committed by
Henry Zhu
parent
2225892348
commit
19c4dd2d8c
@@ -12,7 +12,7 @@
|
||||
"babel-core": "7.0.0-alpha.15",
|
||||
"babel-helper-fixtures": "7.0.0-alpha.15",
|
||||
"babel-polyfill": "7.0.0-alpha.15",
|
||||
"chai": "^3.0.0",
|
||||
"chai": "^4.1.0",
|
||||
"lodash": "^4.2.0",
|
||||
"resolve": "^1.3.2",
|
||||
"source-map": "^0.5.0"
|
||||
|
||||
@@ -18,7 +18,6 @@ import vm from "vm";
|
||||
const moduleCache = {};
|
||||
const testContext = vm.createContext({
|
||||
...helpers,
|
||||
assert: chai.assert,
|
||||
process: process,
|
||||
transform: babel.transform,
|
||||
setTimeout: setTimeout,
|
||||
@@ -26,6 +25,17 @@ const testContext = vm.createContext({
|
||||
});
|
||||
testContext.global = testContext;
|
||||
|
||||
// Add chai's assert to the global context
|
||||
// It has to be required inside the testContext as otherwise some assertions do not
|
||||
// work as chai would reference globals (RegExp, Array, ...) from this context
|
||||
vm.runInContext(
|
||||
"(function(require) { global.assert=require('chai').assert; });",
|
||||
testContext,
|
||||
{
|
||||
displayErrors: true,
|
||||
},
|
||||
)(id => runModuleInTestContext(id, __filename));
|
||||
|
||||
// Initialize the test context with the polyfill, and then freeze the global to prevent implicit
|
||||
// global creation in tests, which could cause things to bleed between tests.
|
||||
runModuleInTestContext("babel-polyfill", __filename);
|
||||
|
||||
Reference in New Issue
Block a user