Skip to content

Commit

Permalink
Pass jest runtime to setup scripts (closes jestjs#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann committed May 6, 2015
1 parent 68f3cbd commit ea97506
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/HasteModuleLoader/HasteModuleLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,10 @@ Loader.prototype.requireModuleOrMock = function(currPath, moduleName) {
}
};

Loader.prototype.getJestRuntime = function(dir){
return this._builtInModules['jest-runtime'](dir).exports;
};

/**
* Clears all cached module objects. This allows one to reset the state of
* all modules in the system. It will reset (read: clear) the export objects
Expand Down
3 changes: 2 additions & 1 deletion src/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ TestRunner.prototype.runTest = function(testFilePath) {
global: env.global,
require: moduleLoader.constructBoundRequire(
config.setupEnvScriptFile
)
),
jest: moduleLoader.getJestRuntime(config.setupEnvScriptFile)
}
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/jasmineTestRunner/jasmineTestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ function jasmineTestRunner(config, environment, moduleLoader, testPath) {
__filename: config.setupTestFrameworkScriptFile,
require: moduleLoader.constructBoundRequire(
config.setupTestFrameworkScriptFile
)
),
jest: moduleLoader.getJestRuntime(config.setupTestFrameworkScriptFile)
}
);
}
Expand Down

0 comments on commit ea97506

Please sign in to comment.