jest icon indicating copy to clipboard operation
jest copied to clipboard

babel-jest does not vary cache by babel environment variables

Open Met48 opened this issue 9 years ago • 10 comments

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

Project uses babel-jest and has a .babelrc with configuration for the test env. The initial run of Jest used a non-test NODE_ENV and failed since the right babel transforms were not applied. After setting NODE_ENV=test, the tests continued to fail with the same error. Adding --no-cache temporarily fixes the error.

What is the expected behavior?

That the cache would vary by the environment variables babel checks, including NODE_ENV and BABEL_ENV.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

Empty Jest config.

Jest v20.0.4 Node v6.9.5 Yarn 0.23.4 NixOS 17.03

Met48 avatar Jun 08 '17 23:06 Met48

What do you think @cpojer?

thymikee avatar Jun 19 '17 20:06 thymikee

Should probably be included in the cache, yes.


From: Michał Pierzchała [email protected] Sent: Monday, June 19, 2017 10:39:34 PM To: facebook/jest Cc: Christoph Pojer; Mention Subject: Re: [facebook/jest] babel-jest does not vary cache by babel environment variables (#3772)

What do you think @cpojerhttps://github.com/cpojer?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/facebook/jest/issues/3772#issuecomment-309566966, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAA0KKR3BUalKNEf9pXkhpX9uciEaMETks5sFtyGgaJpZM4N0uzd.

cpojer avatar Jun 19 '17 21:06 cpojer

@thymikee Could I go with this ?

ajomadlabs avatar Feb 16 '18 15:02 ajomadlabs

Sure!

thymikee avatar Feb 16 '18 15:02 thymikee

@thymikee Since it's my first contribution, could you help me where to get started off

ajomadlabs avatar Feb 16 '18 15:02 ajomadlabs

Here you'll find how babel-jest calculates the cache key: https://github.com/facebook/jest/blob/0285e63e903abbab9c323341e62eb68b29acd87e/packages/babel-jest/src/index.js#L85-L105

Looks like we also need to include information about NODE_NEV and BABEL_ENV (not sure about that though)

thymikee avatar Feb 16 '18 15:02 thymikee

Appears to have been fixed by #3376

njgraf512 avatar Jul 04 '18 22:07 njgraf512

I still have this problem on the latest version 23.6.0, relying on api.env() in babel.config.js to export different config.

Isaddo avatar Oct 02 '18 03:10 Isaddo

PR welcome! Shouldn't be pretty straightforward :)

SimenB avatar Oct 02 '18 07:10 SimenB

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar May 12 '21 10:05 github-actions[bot]