Skip to content

babel-jest's getCacheKey() doesn't take into account options passed to createTransformer() #6698

@edmorley

Description

@edmorley

🐛 Bug Report

babel-jest's getCacheKey uses a variety of factors to generate the hash used for the cache, however currently doesn't include the list of options that were passed to the createTransformer constructor. This means there are incorrect cache hits even when the underlying options have changed.

To Reproduce

Steps to reproduce the behavior:

  1. Create a custom transformer that's referenced by transform in the Jest config:
// transformer.js
const { createTransformer }  = require('babel-jest');

const babelOptions = { presets: ['env'] };

module.exports = createTransformer(babelOptions);
  1. Run jest
  2. Modify the value of babelOptions (for example enabling babel preset-env's debug option)
  3. Run jest again

Expected behavior

When Jest is run the second time, the previous cache entries are not re-used, and the changed babel config is seen in the results.


I'll open a PR to update getCacheKey():
https://github.com/facebook/jest/blob/d05e53a641366fcd1c2532ea845ce6fc8ce42a65/packages/babel-jest/src/index.js#L85-L105

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions