Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
jest-util
Advanced tools
The jest-util package provides utility functions for Jest, a popular JavaScript testing framework. It includes a variety of helpers and tools that are used internally by Jest but can also be useful for developers working with or extending Jest tests.
Console Replacement
This feature allows for the creation of a custom console that buffers all logs. This is useful for controlling and testing console output during test runs.
const { BufferedConsole } = require('jest-util');
const customConsole = new BufferedConsole();
customConsole.log('Hello, this is a buffered log.');
Error Formatting
This function formats execution errors for display in Jest's output, providing a standardized view of test errors, including stack traces.
const { formatExecError } = require('jest-util');
const error = new Error('Test error');
const config = {rootDir: '/path/to/project', testMatch: []};
console.log(formatExecError(error, config, {noStackTrace: false}, undefined, true));
Test Path Normalization
This utility normalizes file paths for glob matching, which is particularly useful on Windows where path separators differ.
const { replacePathSepForGlob } = require('jest-util');
const path = 'path\to\test\file.js';
console.log(replacePathSepForGlob(path));
Chai is an assertion library similar to jest-util in that it is used to help with testing JavaScript applications. Unlike jest-util, Chai focuses more on providing a rich set of assertions rather than utilities for managing Jest environments or outputs.
Mocha is a test framework that, like Jest, can utilize utility packages for enhanced testing capabilities. While jest-util specifically supports Jest, Mocha has its own set of utilities and plugins that serve a similar purpose but are tailored to Mocha's ecosystem.
Sinon provides standalone test spies, stubs, and mocks for JavaScript. It complements jest-util by offering more focused functionalities for creating and managing test doubles, which can be used alongside or independently of Jest.
jest-cli 11.0.0, babel-jest 11.0.0 (pre-releases 0.9 to 0.10)
testRunner: "jasmine1"
into your configuration.jest-util
, jest-mock
, jest-jasmine1
, jest-jasmine2
, jest-environment-node
, jest-environment-jsdom
packages.babel-jest-preset
and babel-jest
as packages. babel-jest
is now being auto-detected.babel-plugin-jest-hoist
which hoists jest.unmock
, jest.mock
and the new jest.enableAutomock
and jest.disableAutomock
API.babel-jest
integration and react-native
testing.babel-jest
.jest.mock('moduleName', moduleFactory)
feature. jest.mock
now gets hoisted by default. jest.doMock
was added to explicitly mock a module without the hoisting feature of babel-jest
.--watch
.--watch
.--watch
will now only runs tests related to changed files. --watch=all
can be used to run all tests on file system changes.--watch
re-runs to not trigger test runs during a branch switch in version control.jest.fn()
and jest.fn(implementation)
as convenient shortcuts for jest.genMockFunction()
and jest.genMockFunction().mockImplementation()
.automock
option to turn off automocking globally.process.NODE_ENV
to test
unless otherwise specified.moduleNameMapper
config option when used with paths.throw 'string errors'
.--onlyChanged
option.toBeCalled
Jasmine 2 custom matcher messages.xit
and xdescribe
.preprocessCachingDisabled
config option.testEnvironment
option to customize the sandbox environment.@scoped/name
npm packages.FAQs
This packages is a collection of utilities and helper functions
The npm package jest-util receives a total of 42,987,179 weekly downloads. As such, jest-util popularity was classified as popular.
We found that jest-util 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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.