Socket
Socket
Sign inDemoInstall

jest-util

Package Overview
Dependencies
19
Maintainers
6
Versions
259
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-util


Version published
Maintainers
6
Install size
2.84 MB
Created

Package description

What is jest-util?

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.

What are jest-util's main functionalities?

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));

Other packages similar to jest-util

Changelog

Source

29.1.0

Features

  • [expect, @jest/expect] Support type inference for function parameters in CalledWith assertions (#13268)
  • [expect, @jest/expect] Infer type of *ReturnedWith matchers argument (#13278)
  • [@jest/environment, jest-runtime] Allow jest.requireActual and jest.requireMock to take a type argument (#13253)
  • [@jest/environment] Allow jest.mock and jest.doMock to take a type argument (#13254)
  • [@jest/fake-timers] Add jest.now() to return the current fake clock time (#13244, #13246)
  • [@jest/mock] Add withImplementation method for temporarily overriding a mock (#13281)
  • [expect] Export toThrow* matchers (#13328)

Fixes

  • [jest-circus, jest-jasmine2] Fix error messages for Node's assert.throes (#13322)
  • [jest-haste-map] Remove __proto__ usage (#13256)
  • [jest-mock] Improve spyOn typings to handle optional properties (#13247)
  • [jest-mock] Fix mocking of getters and setters on classes (#13145)
  • [jest-snapshot] Throw useful error when an array is passed as property matchers (#13263)
  • [jest-snapshot] Prioritize parser used in the project (#13323)
  • [jest-transform] Attempt to work around issues with atomic writes on Windows (#11423)

FAQs

Last updated on 28 Sep 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc