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

Do not remove .babelrc! May break Jest tests written in ES6 #8

Open
aschrijver opened this issue Jul 11, 2017 · 0 comments
Open

Do not remove .babelrc! May break Jest tests written in ES6 #8

aschrijver opened this issue Jul 11, 2017 · 0 comments

Comments

@aschrijver
Copy link

aschrijver commented Jul 11, 2017

I am using the ignite boilerplate and I just want to point out that you shouldn't delete the .babelrc file when replacing its content with babel-transformer.js!

Doing this leads to Jest tests stop working due to the ES6 code of the tests not being recognized properly. You get the dreaded:

FAIL  Tests/Sagas/StartupSagaTest.js
  ● Test suite failed to run

    /home/myself/MyProject/Tests/Sagas/StartupSagaTest.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { select, put } from 'redux-saga/effects';
                                                                                             ^^^^^^
    
    SyntaxError: Unexpected token import
      
      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
      at handle (node_modules/worker-farm/lib/child/index.js:44:8)
      at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:51:3)
      at emitTwo (events.js:125:13)

I did delete the .babelrc and it took me a ton of time to find the issue. Now I have this .babelrc in the root of the project:

{
  "env": {
    "test": {
      "presets": ["react-native"],
      "plugins": ["transform-es2015-modules-commonjs"]
    }
  }
}

And add NODE_ENV=test to the test task in package.json.

@aschrijver aschrijver changed the title Breaks Ignite boilerplate Jest tests Do not remove .babelrc! May break Jest tests written in ES6 Jul 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant