Socket
Socket
Sign inDemoInstall

jest-haste-map

Package Overview
Dependencies
24
Maintainers
5
Versions
270
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-haste-map


Version published
Weekly downloads
26M
decreased by-18.87%
Maintainers
5
Install size
394 kB
Created
Weekly downloads
 

Package description

What is jest-haste-map?

The jest-haste-map npm package is a utility for building a Haste map, which is a mapping from module names to file paths. It is used by Jest to quickly resolve module dependencies for tests by keeping an in-memory map of all available modules. It can handle duplicate module names and provides a way to query the map for a specific module.

What are jest-haste-map's main functionalities?

Building a Haste Map

This code sample demonstrates how to create a new HasteMap instance with a configuration object, build the map, and then use it to get the module name for a specific file.

const HasteMap = require('jest-haste-map');
const config = {
  // These options are required:
  roots: ['/path/to/project'],
  extensions: ['js', 'json'],
  platforms: ['ios', 'android'],
  // You can provide additional options:
  computeSha1: true,
  // other options...
};
const hasteMap = new HasteMap(config);
hasteMap.build().then(map => {
  console.log(map.hasteFS.getModuleName('/path/to/project/file.js'));
});

Querying the Haste Map

This code sample shows how to query the built Haste map for the path of a module given its name, platform, and whether it supports the native platform.

hasteMap.build().then(map => {
  const modulePath = map.moduleMap.getModule('moduleName', 'platform', 'supportsNativePlatform');
  console.log(modulePath);
});

Other packages similar to jest-haste-map

Changelog

Source

jest 18.0.0

See https://jestjs.io/blog/2016/12/15/2016-in-jest

  • The testResultsProcessor function is now required to return the modified results.
  • Removed pit and mockImpl. Use it or mockImplementation instead.
  • Fixed re-running tests when --bail is used together with --watch.
  • pretty-format is now merged into Jest.
  • require('v8') now works properly in a test context.
  • Jest now clears the entire scrollback in watch mode.
  • Added expect.any, expect.anything, expect.objectContaining, expect.arrayContaining, expect.stringMatching.
  • Properly resolve snapshotSerializers, setupFiles, transform, testRunner and testResultsProcessor instead of using path.resolve.
  • --testResultsProcessor is now exposed through the cli.
  • Renamed --jsonOutputFile to --outputFile.
  • Added jest-editor-support for vscode and Nuclide integration.
  • Fixed test.concurrent unhandled promise rejections.
  • The Jest website is now auto-deployed when merging into main.
  • Updated testRegex to include test.js and spec.js files.
  • Fixes for babel-plugin-jest-hoist when using jest.mock with three arguments.
  • The JSON global in jest-environment-node now comes from the vm context instead of the parent context.
  • Jest does not print stack traces from babel any longer.
  • Fake timers are reset when FakeTimers.useTimers() is called.
  • Usage of Jest in watch mode can be hidden through JEST_HIDE_USAGE.
  • Added expect.assertions(number) which will ensure that a specified amount of assertions is made in one test.
  • Added .toMatchSnapshot(?string) feature to give snapshots a name.
  • Escape regex in snapshots.
  • jest-react-native was deprecated and now forwards react-native.
  • Added .toMatchObject matcher.
  • Further improve printing of large objects.
  • Fixed NaN% Failed in the OS notification when using --notify.
  • The first test run without cached timings will now use separate processes instead of running in band.
  • Added .toHaveProperty matcher.
  • Fixed Map/Set comparisons.
  • test.concurrent now works with --testNamePattern.

FAQs

Last updated on 15 Dec 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