I am trying to run jest tests after switching to laptop. Before, on computer every test was launching and no syntax/runtime errors were returned, but now when I try to run them on laptop, they return me error:
C:\PROJECT_DIR\foo.test.js
...initialState,
^^^
SyntaxError: Unexpected token ...
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:318:17)
What could cause this? I did npm install, everything is installed, and yet I keep getting this error even though it did not occur on previous machine.
This is the test:
import increments from '../increments'
const initialState = {
goldBase: 0,
goldMulti: 1,
goldIncr: 0,
coalBase: 0,
coalMulti: 1,
coalIncr: 0,
ironBase: 0,
ironMulti: 1,
ironIncr: 0,
stoneBase: 0,
stoneMulti: 1,
stoneIncr: 0,
woodBase: 0,
woodMulti: 1,
woodIncr: 0,
foodBase: 0,
foodMulti: 1,
foodIncr: 0
}
describe('increments', () => {
it('should properly increment values of base increments', () => {
const action = {
type: 'INCREMENT',
goldBase: 1,
coalBase: 0.2,
ironBase: 0.8,
stoneBase: NaN,
woodBase: undefined,
foodBase: null
};
const testState = {
...initialState,
coalBase: 0.1
};
const expectedState = {
...initialState,
goldBase: 1,
coalBase: 0.3,
ironBase: 0.8,
};
expect(increments(testState, action)).toEqual(expectedState);
});
And here is package.json:
{
"name": "foo",
"version": "0.1.0",
"description": "",
"private": true,
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-scripts": "1.1.0",
"redux": "^3.7.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"test:watch": "npm test -- --watch",
"eject": "react-scripts eject"
},
"author": "",
"license": "MIT",
"homepage": "",
"devDependencies": {
"babel-jest": "^22.1.0",
"babel-preset-es2015": "^6.24.1",
"jest": "^22.1.4"
},
"babel": {
"presets": [
"es2015"
]
}
}
Aucun commentaire:
Enregistrer un commentaire