Jest: babel-jest always installed by default

Created on 9 Feb 2017  ·  1Comment  ·  Source: facebook/jest

When I currently install jest it will automatically also install babel-jest.

└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └── [email protected] 

According to the docs, to enable babel transpilliation you just have to install babel-jest, but it will always be installed be default, so everyone (using npm >= 3) will always use babel to precompile, even if not necessary.

Is this intended or is there a way to tell jest to not use babel? To me it looks like it might not be needed and this is actually a (potential performance) bug, but it is the first time I look at the jest src.

I can create a PR to remove babel-jest from jest-runtime (The tests work just fine without it and it is not used in the src)
Or I can create a PR for the docs if you tell me how it works :)

I noticed this while trying to move babylon from ava to jest. There we run the tests agains a rollup-bundle that is already transpiled.
By default I get this error, which is babel trying to transpile the same bundle again:

  ● Test suite failed to run

    ReferenceError: babelHelpers is not defined

      at Object.<anonymous> (../lib/index.js:129:73)
      at Object.<anonymous> (index.js:3:15)

If I delete babel-jest from the node-modules folder by hand it works perfectly :

Test Suites: 1 passed, 1 total
Tests:       59 skipped, 2492 passed, 2551 total
Snapshots:   0 total
Time:        3.696s, estimated 5s

Most helpful comment

You can do "transform: {}" in Jest or customize your transformers.

http://facebook.github.io/jest/docs/configuration.html#content

>All comments

You can do "transform: {}" in Jest or customize your transformers.

http://facebook.github.io/jest/docs/configuration.html#content

Was this page helpful?
0 / 5 - 0 ratings