jest-runtime
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@jest/environment | 29.7.0 | 5.2 kB | MIT | prod | |
@jest/fake-timers | 29.7.0 | 6.1 kB | MIT | prod | |
@jest/globals | 29.7.0 | 1.9 kB | MIT | prod | 1 1 |
@jest/source-map | 29.6.3 | 2.19 kB | MIT | prod | |
@jest/test-result | 29.7.0 | 4.21 kB | MIT | prod | |
@jest/transform | 29.7.0 | 12.12 kB | MIT | prod | 1 1 |
@jest/types | 29.6.3 | 8 kB | MIT | prod | |
@types/node | 20.14.10 | 1.99 MB | MIT | prod | |
chalk | 4.1.2 | 11.31 kB | MIT | prod | |
cjs-module-lexer | 1.3.1 | 136.14 kB | MIT | prod | |
collect-v8-coverage | 1.0.2 | 2.44 kB | MIT | prod | |
glob | 7.2.3 | 15.08 kB | ISC | prod | |
graceful-fs | 4.2.11 | 9.57 kB | ISC | prod | |
jest-haste-map | 29.7.0 | 27.91 kB | MIT | prod | |
jest-message-util | 29.7.0 | 6.84 kB | MIT | prod | |
jest-mock | 29.7.0 | 11.69 kB | MIT | prod | |
jest-regex-util | 29.6.3 | 1.65 kB | MIT | prod | |
jest-resolve | 29.7.0 | 12.81 kB | MIT | prod peer | |
jest-snapshot | 29.7.0 | 19.07 kB | MIT | prod | 1 1 |
jest-util | 29.7.0 | 10.86 kB | MIT | prod | |
slash | 3.0.0 | 1.8 kB | MIT | prod | |
strip-bom | 4.0.0 | 2.07 kB | MIT | prod |
Jest-Runtime is a core package of the Jest testing platform. It is responsible for the essential functionality of evaluating and running your test code within a controlled environment. It works by compiling and executing your test files and their dependencies in isolation for each test suite, thereby ensuring accurate and uncorrupted test results.
To use jest-runtime, you'll first need to install it as a part of Jest npm package using either npm or yarn:
npm install --save jest
or
yarn add jest
Having installed Jest, jest-runtime is available for you to use. However, direct usage of jest-runtime is generally reserved for advanced use-cases.
Here's a simple Node.js script example that demonstrates how to use jest-runtime:
const Runtime = require('jest-runtime');
const path = require('path');
async function run() {
const config = Runtime.createHasteMap.getDefaultConfig({
rootDir: process.cwd(),
});
const hasteMap = await Runtime.createHasteMap(config);
const resolver = Runtime.createResolver(
config,
hasteMap.moduleMap,
);
const runtime = new Runtime(config, resolver);
runtime.requireModule(runtime.__mockRootPath, './test-to-run.js');
}
run();
In this script, we load a test script located at ./test-to-run.js
using jest-runtime.
The documentation for jest-runtime can be found as part of Jest's official documentation on their website here. While the package's documentation may not be as rich or detailed as that of the main Jest library, the overall Jest documentation will provide further insights into its usage and capabilities.