Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
jest-runtime
Advanced tools
The jest-runtime package is part of the Jest testing platform. It is responsible for executing tests and their associated code within a controlled environment. It handles the evaluation of the test files, mocking of modules, and provides utilities for loading and running the tests.
Module Mocking
Allows you to mock modules to isolate your tests from their dependencies, providing a way to test modules in isolation.
jest.mock('moduleName');
Test Environment Setup
Enables you to programmatically create a test environment, including the haste map (module map) and the test runner, which can be used to execute test files.
const runtime = require('jest-runtime');
// Create a runtime to execute the test
runtime.createHasteMap(config).then(hasteMap => {
const environment = new runtime.TestEnvironment(config);
const runner = new runtime.TestRunner(environment, hasteMap.resolver);
// Execute the test file
runner.runTest(filePath);
});
Script Transformation
Provides the ability to transform scripts using Jest's built-in transformers or custom ones. This is useful for preprocessing files before they are executed in the test environment.
const runtime = require('jest-runtime');
// Create a new runtime instance
const jestRuntime = new runtime.ScriptTransformer(config);
// Transform a script
const transformedCode = jestRuntime.transformSource(filePath, fileContent, false);
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple. It is similar to jest-runtime in that it provides a test environment and runner, but it does not include a built-in mocking library or script transformation capabilities.
Jasmine is a behavior-driven development framework for testing JavaScript code. It does not require a DOM, and it has a clean, obvious syntax so that you can easily write tests. It is similar to jest-runtime in providing an environment for running tests, but it has a different assertion library and does not handle module mocking and script transformation in the same way.
AVA is a test runner for Node.js with a concise API, detailed error output, and process isolation that lets you develop with confidence. AVA is similar to jest-runtime in that it can run tests in parallel and supports the latest JavaScript features, but it differs in its approach to mocking and does not provide a built-in mechanism for script transformation.
jest 16.0.0
jest <pattern>
is now case-insensitive.it.only
, it.skip
, test.only
, test.skip
and xtest
.--testNamePattern=pattern
or -t <pattern>
to run individual tests in test files.a
, o
, p
, q
or enter
while tests are running in the watch mode, the test run will be interrupted.--bail
now works together with --watch
.test.concurrent
for concurrent async tests..jsx
extension.jest.clearAllMocks
to clear all mocks manually.jest-snapshot
can now be more easily integrated into other test runners and used in other projects.fit
or when an error is thrown in a test.toHaveBeenLastCalledWith
, toHaveBeenCalledWith
, lastCalledWith
and toBeCalledWith
failure messages.toBeInstanceOf
matcher.toContainEqual
matcher.toThrowErrorMatchingSnapshot
matcher.moduleNameMapper
resolution.setupTestFrameworkScriptFile
script to make it easier to use chai together with Jest.--findRelatedTests <fileA> <fileB>
cli option to run tests related to the specified files.jest.deepUnmock
to babel-plugin-jest-hoist
.jest.runTimersToTime
which is useful together with fake timers.FAQs
Unknown package
The npm package jest-runtime receives a total of 10,905,073 weekly downloads. As such, jest-runtime popularity was classified as popular.
We found that jest-runtime demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.