Socket
Socket
Sign inDemoInstall

@jest/create-cache-key-function

Package Overview
Dependencies
16
Maintainers
6
Versions
72
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jest/create-cache-key-function

This module creates a function which is used for generating cache keys used by code transformers in Jest.


Version published
Weekly downloads
3.3M
decreased by-1.62%
Maintainers
6
Created
Weekly downloads
 

Changelog

Source

29.0.2

Features

  • [jest-transform] Expose TransformFactory type (#13184)

Fixes

  • [babel-plugin-jest-hoist] Support imported jest in mock factory (#13188)
  • [jest-mock] Align the behavior and return type of generateFromMetadata method (#13207)
  • [jest-runtime] Support jest.resetModules() with ESM (#13211)

Readme

Source

jest-create-cache-key-function

This module creates a function which is used for generating cache keys used by code transformers in Jest.

Install

$ npm install --save-dev @jest/create-cache-key-function

API

createCacheKey(files?: Array<string>, values?: Array<String>): GetCacheKeyFunction

Get a function that can generate cache keys using source code, provided files and provided values.

Parameters
  • files: [Optional] Array of absolute paths to files whose code should be accounted for when generating cache key
  • values: [Optional] Array of string values that should be accounted for when generating cache key

Note:

The source code for your test is already taken into account when generating the cache key. The files array should be used to provide files that are not directly related to your code such as external configuration files.

Usage

Here is some sample usage code while creating a new transformer for Jest

const createCacheKeyFunction =
  require('@jest/create-cache-key-function').default;

const filesToAccountFor = [
  __filename,
  require.resolve('some-package-name/package.json'),
];

const valuesToAccountFor = [process.env.SOME_LOCAL_ENV, 'Some_Other_Value'];

module.exports = {
  process(src, filename, config, options) {},
  getCacheKey: createCacheKeyFunction(filesToAccountFor, valuesToAccountFor),
};

FAQs

Last updated on 03 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