yarn test fails
See original GitHub issueDescription
I want to run tests. Might be related to: https://github.com/react-community/create-react-native-app/issues/199
Expected Behavior
Tests succeed.
Observed Behavior
Tests always fail. With a variety of syntax errors.
Environment
Please run these commands in the project folder and fill in their results:
npm ls react-native-scripts
: 1.11.1npm ls react-native
: 0.52.0npm ls expo
: 25.0.0node -v
: v8.1.1npm -v
: 5.0.3yarn --version
: 1.3.2watchman version
: 4.7.0
Also specify:
- Operating system: Mac OSX High Sierra
- Phone/emulator/simulator & version: N/A
Reproducible Demo
I got only one test, it’s the default test CRNA creates.
I have created a minimal example of what makes CRNA fail when running yarn test
.
It is after this commit where yarn test
starts to fail https://github.com/watadarkstar/minimal-failing-crna-yarn-test/commit/94fdee722f773196f80b349f0d8ae970e4ed3d04
The minimal example can be found here: https://github.com/watadarkstar/minimal-failing-crna-yarn-test
I try to run it with yarn test
I get SyntaxError: Unexpected token import
in many source files. I get this with the default package.json
:
node_modules/native-base-shoutem-theme/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import connectStyle from "./src/connectStyle";
^^^^^^
SyntaxError: Unexpected token import
1 | import React from 'react';
> 2 | import { Text, View } from 'native-base';
3 | import { StackNavigator } from 'react-navigation';
4 | import { Home, Quiz, Results } from './components/screens';
5 |
My .babelrc
:
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
My package.json
:
"test": "node node_modules/jest/bin/jest.js"
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
I’m not sure we can provide a more user-friendly message. Do you have ideas for how we could practically do that?
One fix people could apply on their own, if they want to bear the cost of more transforms, is to set
transformIgnorePatterns: []
.@ide I can agree from a technical perspective this works as expected once you dive into the issue. Although from a user’s perspective, many people will run into this issue as soon as they add a package that doesn’t need to be transpiled and then run
yarn test
. It would be nice if there was a more user-friendly solution.Another alternative is to provide a more meaningful error message when these transpile errors occur in
node_modules
from Jest, but I don’t know enough about how Jest works.