Jest: babel-jest transforming dependencies

Created on 31 Oct 2016  Â·  2Comments  Â·  Source: facebook/jest

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

Feature

What is the current behavior?

babel-jest doesn't transform package dependencies.

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 and npm test.

We have a Lerna repo where one package depends on another. Jest will compile the immediate package, but skip compiling dependencies. This inevitably leads to errors like:

import Element from './element'
    ^^^^^^
    SyntaxError: Unexpected token import

What is the expected behavior?

It just works I guess? Not 100% sure of what the preferred fix would be.

Most helpful comment

You can adjust preprocessorIgnorePatterns to also transform node_modules. The problem with that is that the initial run of Jest is going to be a lot slower, which is why it isn't a default.

In Jest itself, this isn't a problem (we also use lerna): with npm run watch we continuously compile changes and every package's package.json points to build/index.js instead of src/index.js. This works really well – I suggest using the same kind of setup we have in this repo :)

All 2 comments

You can adjust preprocessorIgnorePatterns to also transform node_modules. The problem with that is that the initial run of Jest is going to be a lot slower, which is why it isn't a default.

In Jest itself, this isn't a problem (we also use lerna): with npm run watch we continuously compile changes and every package's package.json points to build/index.js instead of src/index.js. This works really well – I suggest using the same kind of setup we have in this repo :)

Awesome, thanks for the reply — appreciate the insight.

On Mon, Oct 31, 2016 at 6:47 PM Christoph Pojer [email protected]
wrote:

You can adjust preprocessorIgnorePatterns to also transform node_modules.
The problem with that is that the initial run of Jest is going to be a lot
slower, which is why it isn't a default.

In Jest itself, this isn't a problem (we also use lerna): with npm run
watch we continuously compile changes and every package's package.json
points to build/index.js instead of src/index.js. This works really well
– I suggest using the same kind of setup we have in this repo :)

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/facebook/jest/issues/2034#issuecomment-257470531, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAACzmH-ujemQFDDewWN6H2GX0HbjHK3ks5q5podgaJpZM4Klior
.

Was this page helpful?
0 / 5 - 0 ratings