Socket
Socket
Sign inDemoInstall

jest-haste-map

Package Overview
Dependencies
130
Maintainers
7
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
32M
decreased by-0.49%
Maintainers
7
Install size
4.65 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

26.6.2

Features

  • [jest-core] Add findRelatedTests and nonFlagArgs in allowed config options for updateConfigAndRun in watch plugins (#10659)

Fixes

  • [babel-plugin-jest-hoist] Preserve order of hoisted mock nodes within containing block (#10536)
  • [babel-plugin-jest-hoist] Hoist pure constants to support experimental JSX transform in hoisted mocks (#10723)
  • [babel-preset-jest] Update babel-preset-current-node-syntax to support top level await (#10747)
  • [expect] Revert "Fix objectContaining to work recursively into sub-objects (#10508)" (#10766)
  • [jest-circus, jest-jasmine2] fix: don't assume stack is always a string (#10697)
  • [jest-config] Fix bug introduced in watch mode by PR #10678 (#10692)
  • [jest-config] Throw correct error for missing preset modules (#10737)
  • [jest-resolve-dependencies] Resolve mocks as dependencies (#10713)
  • [jest-runtime] Handle file URLs in dynamic imports (#10744)
  • [jest-runtime, babel-jest] Pass more ESM options to @jest/transform (#10752)
  • [jest-runtime] Properly inject extraGlobals into the runtime (#10758)
  • [jest-transform] Link to ESM docs on syntax errors (#10748)

Chore & Maintenance

  • [docs] Add docs for using mocks in TypeScript (#10415)
  • [eslint-config-fb-strict] Move package from this repo to fbjs repo (#10739)
  • [examples] Update TypeScript example to show use of newer Jest types (#10399)
  • [jest-cli] chore: standardize files and folder names (#10698)
  • [jest-config] Switch ts-node Register type to Service due to deprecation (#11210)

FAQs

Last updated on 02 Nov 2020

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