Socket
Socket
Sign inDemoInstall

jest-util

Package Overview
Dependencies
12
Maintainers
5
Versions
260
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-util


Version published
Weekly downloads
53M
decreased by-1.26%
Maintainers
5
Install size
505 kB
Created
Weekly downloads
 

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

jest-cli 12.1.0

  • Jest is now also published in the jest package on npm.
  • Added testRegex to match for tests outside of specific folders. Deprecated both testDirectoryName and testFileExtensions.
  • it can now return a Promise for async testing. pit was deprecated.
  • Added jest-resolve as a standalone package based on the Facebook module resolution algorithm.
  • Added jest-changed-files as a standalone package to detect changed files in a git or hg repo.
  • Added --setupTestFrameworkFile to cli.
  • Added support for coverage thresholds. See https://jestjs.io/docs/configuration#coveragethreshold-object.
  • Updated to jsdom 9.0.
  • Updated and improved stack trace reporting.
  • Added module.filename and removed the invalid module.__filename field.
  • Further improved the lastCalledWith and toBeCalledWith custom matchers. They now print the most recent calls.
  • Fixed jest-haste-map on continuous integration systems.
  • Fixes for hg/git integration.
  • Added a re-try for the watchman crawler.

FAQs

Last updated on 20 May 2016

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