29.7.0 • Published 2 months ago

@jest/create-cache-key-function v29.7.0

Weekly downloads
148,413
License
MIT
Repository
github
Last release
2 months ago

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>, length?: number): GetCacheKeyFunction

Returns a function that can be used to generate cache keys based on source code of 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
  • length: Optional Length of the resulting key. The default is 32, or 16 on Windows.

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),
};
30.0.0-alpha.3

2 months ago

29.6.3

9 months ago

29.6.0

10 months ago

29.6.1

10 months ago

29.6.2

9 months ago

30.0.0-alpha.2

6 months ago

30.0.0-alpha.1

6 months ago

29.7.0

8 months ago

29.5.0

1 year ago

29.4.2

1 year ago

29.4.3

1 year ago

29.4.1

1 year ago

29.4.0

1 year ago

29.3.1

1 year ago

29.2.0

2 years ago

29.2.1

2 years ago

29.1.0

2 years ago

29.1.2

2 years ago

29.0.1

2 years ago

29.0.2

2 years ago

29.0.3

2 years ago

29.0.0

2 years ago

28.1.3

2 years ago

29.0.0-alpha.6

2 years ago

29.0.0-alpha.4

2 years ago

29.0.0-alpha.3

2 years ago

29.0.0-alpha.0

2 years ago

28.1.0

2 years ago

28.1.1

2 years ago

28.0.0

2 years ago

28.0.1

2 years ago

28.0.2

2 years ago

28.0.0-alpha.8

2 years ago

28.0.0-alpha.9

2 years ago

28.0.0-alpha.6

2 years ago

28.0.0-alpha.7

2 years ago

28.0.0-alpha.4

2 years ago

28.0.0-alpha.3

2 years ago

28.0.0-alpha.5

2 years ago

27.5.0

2 years ago

27.5.1

2 years ago

28.0.0-alpha.0

2 years ago

28.0.0-alpha.2

2 years ago

28.0.0-alpha.1

2 years ago

27.4.0

2 years ago

27.4.1

2 years ago

27.4.2

2 years ago

27.2.5

3 years ago

27.3.0

3 years ago

27.3.1

3 years ago

27.2.3

3 years ago

27.2.4

3 years ago

27.2.0

3 years ago

27.1.1

3 years ago

27.1.0

3 years ago

27.0.6

3 years ago

27.0.2

3 years ago

27.0.0-next.9

3 years ago

27.0.0-next.11

3 years ago

27.0.0-next.10

3 years ago

27.0.1

3 years ago

27.0.0-next.8

3 years ago

27.0.0-next.7

3 years ago

27.0.0-next.6

3 years ago

27.0.0-next.4

3 years ago

27.0.0-next.3

3 years ago

27.0.0-next.1

3 years ago

27.0.0-next.0

3 years ago

26.6.2

4 years ago

26.5.0

4 years ago