Skip to content

Commit

Permalink
Merge pull request #354 from johannhof/jest-in-setup
Browse files Browse the repository at this point in the history
Pass jest runtime to test setup scripts (closes #108)
  • Loading branch information
DmitrySoshnikov committed May 8, 2015
2 parents 732c8a2 + 36654e0 commit 48a157c
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 48a157c

Please sign in to comment.