Socket
Socket
Sign inDemoInstall

jest-haste-map

Package Overview
Dependencies
37
Maintainers
6
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
27M
decreased by-17.96%
Maintainers
6
Install size
2.46 MB
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

27.4.0

Features

  • [expect] Enhancing the toHaveProperty matcher to support array selection (#12092)
  • [jest-core] Add support for testResultsProcessor written in ESM (#12006)
  • [jest-diff, pretty-format] Add compareKeys option for custom sorting of object keys (#11992)
  • [jest-mock] Add ts-jest mock util functions (#12089)

Fixes

  • [expect] Allow again expect.Matchers generic with single value (#11986)
  • [jest-circus, jest-jasmine2] Avoid false concurrent test failures due to unhandled promise rejections (#11987)
  • [jest-config] Add missing slash dependency to package.json (#12080)
  • [jest-core] Incorrect detection of open ZLIB handles (#12022)
  • [jest-diff] Break dependency cycle (#10818)
  • [jest-environment-jsdom] Add @types/jsdom dependency (#11999)
  • [jest-environment-jsdom] Do not reset the global.document too early on teardown (#11871)
  • [jest-transform] Improve error and warning messages (#11998)
  • [jest-worker] Pass execArgv correctly to worker_threads worker (#12069)

Chore & Maintenance

  • [docs] CLI options alphabetized (#11586)
  • [jest-runner] Add info regarding timers to forcedExit message(#12083)
  • [*] Replaced substr method with substring (#12066)
  • [*] Add types entry to all export maps (#12073)

FAQs

Last updated on 29 Nov 2021

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