really battling here.
My Circle CI tests have failed with a
FAIL ./App.test.js
● Test suite failed to run
SyntaxError: Unexpected token )
I try to run Jest locally on my machine (a CRNA one) but i get the following error:
TypeError: environment.setup is not a function
So both of these appear to be node version/ES6/babel issues, right?
I battled through some errors before (Path was expecting string
etc), which i got round by install jest-cli and changing node versions etc.
i am now on: node v8.9.1 npm 5.5.1
But now i'm totally stumped.
So:
TypeError: environment.setup is not a function
is specific to jest-cli package.
i've tried:
i) adding in the following to the jest config in pkg json:
"jest": {
"preset": "jest-expo",
"testMatch": [
"*.test.js",
"**/?(*.)(spec|test).js?(x)"
],
"transformIgnorePatterns": [
"node_modules/(?!(react-native|jest-cli)/)"
]
}
(thought this might 'babel' the module, but alas no change in error msg)
ii) Changing versions of babel-core, installing babel-node-modules, changing versions of React Native, jest etc etc. No joy.
Help?
Is there something i'm missing in terms of getting a Create React Native App project to run jest tests on node v5-v8?
Proper stumped and it's holding up getting my Circle CI set-up.
Send help or some sort of IPA ale to sooth my frustration. 😒
I ended up getting this working by:
i) installing babel-jest
ii) babel-preset-react-native
(instead of the stage-0 module)
iii) changing the test script to just test: jest
iv) removing env variable from .babelrc (so it's just "presets": ["react-native"]
now)
v) changing my config.yml
to a circle.yml
(this got rid of a node version error)
vi) nuking node_modules, full npm install
(/yarn
)
vii) moved my App.test.js
out of the root and into its own __tests__/App.test.js
folder/location.
I think babel-jest was the main crux of it, but even then I was getting propTypes not found errors and had to check my peer dependencies, some of which needed updating past the beta versions of things I had been using.
My package json:
{
"name": "MyAppName",
"jest": {
"preset": "react-native"
},
"version": "0.1.0",
"private": true,
"devDependencies": {
"babel-eslint": "^8.0.1",
"babel-jest": "21.2.0",
"babel-preset-react-native": "4.0.0",
"babel-plugin-module-resolver": "^3.0.0",
"enzyme": "^3.2.0",
"enzyme-adapter-react-16": "^1.1.0",
"eslint": "^4.9.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-react": "^7.4.0",
"flow-bin": "0.53.1",
"jest": "^21.2.1",
"react-dom": "^16.2.0",
"react-test-renderer": "16.2.0",
"sinon": "^4.1.3"
},
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test": "jest"
},
"dependencies": {
"jest-cli": "^21.2.1",
"react": "16.2.0",
"react-native": "^0.51.0"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With