Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest does not respect .babelrc env:test after failing with modules:false #3129

Closed
Lokua opened this issue Mar 13, 2017 · 3 comments
Closed

Comments

@Lokua
Copy link

Lokua commented Mar 13, 2017

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

What is the current behavior?
Jest is ignoring babelrc env:test settings, sometimes. Seems that after jest has failed from a babelrc misconfig, it can not recover even when the config has been corrected (as if .babelrc is being cached only when an error happens).

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

Bare with me, this is pretty annoying.

https://github.com/Lokua/throw-away-jest-repro.

If you clone, yarn install, and yarn test - everything will pass! Great! This was a huge surprise to me because I discovered this after cloning this reproduction to confirm that you'd see it fail like I am locally. Huh? In other words my original origin is failing, but the clone of remote that came from origin isn't (exact same code)!?

Now, change .bablerc to look like the following:

{
  "presets": [
    ["env", {
      "modules": false
    }]
  ]
}

This will understandably fail because of the modules: false for all envs. But now here's the thing, put the .babelrc back the way it was, with the "env":{"test":{"presets":[["env", {"modules":"commonjs"}]]}} part, and your tests that used to pass under this exact config should fail. At least in a messed up way I hope it does so we can get to the bottom of this! ;P

What is the expected behavior?
I would expect the before and after scenarios mentioned above to output the same results.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
node 6.8.0
npm 3.10.8
yarn 0.19.1
jest 19.0.2
OSX El Capitan 10.11.5

Also, for good measure, I have tried removing and reinstalling after the failure. I have also ran yarn cache clean && rm -rvf node_modules && yarn install && yarn test. Once it fails, the correct config makes no difference.

The test will pass if a) fresh clone of repo or b) copy files (after the whole failure switcharoo scenario) to a new directory.

@Lokua
Copy link
Author

Lokua commented Mar 13, 2017

Sorry to spam your issues. I just went through the steps I mentioned above again (fresh clone, switched babelrc back and forth), and the tests do pass again. The original local repo, however, which is the same code (with env:test part), still won't pass. Copying the code from this local repo to a different folder, however, does result in passing tests. Wish I could provide you with something more concretely reproducible.

@cpojer
Copy link
Member

cpojer commented Mar 13, 2017

Try to run Jest with --no-cache once when you change .babelrc.

@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants