Closed MoOx closed 8 years ago
I finished by understanding that "test" is used. But this can be confusing when you don't know. Maybe it should just be added into the doc? (Near babel-jest part)
Yeah you are right, we should add documentation for this. Jest sets the NODE_ENV to test if it isn't provided and otherwise let's you use a custom override. We don't use BABEL_ENV at all. I'm gonna close as wontfix but I'm happy to accept a PR for documentation.
@cpojer I think babel-core
's transform
should handle reading BABEL_ENV
but you need to pass along env
from the user's configuration into it, which seems like it may not be happening here? Unless we're relying on Babel to do that since we're not disabling babelrc
option. https://github.com/facebook/jest/blob/ab6f4c3001a2cd917cc4df95e42dfc72f23c5a00/packages/babel-jest/src/index.js#L70
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.
Do you want to request a feature or report a bug?
I think I found a bug while converting some tests from AVA to Jest. (AVA also handle babel transformation, but jest does do the transform the same way, see below).
What is the current behavior?
I am using the first react example from the website homepage and I am getting an "Unexpected token" on the
<a
. This is because my babel configuration is not correctly interpreted.Currently, it seems that babel-jest does not interpret babelrc/env.development configuration by default. According to babelrc doc, when no BABEL_ENV / NODE_ENV are specified, "development" is used for the "env".
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can
npm install
andnpm test
.Currently, I don't have any babel configuration by default. I am using webpack 2 & does not need
import
s to be transformed blahblah so here is my configurationAs you can see, all my configs are in "env".
What is the expected behavior?
I expect jest to set BABEL_ENV to "development" if
NODE_ENV==="" && BABEL_ENV === ""
.If I launch jest with
NODE_ENV=development
it works.Run Jest again with
--debug
and provide the full configuration it prints. Please mention your node and npm version and operating system.Here is the working line