I was trying to implement the example shown in Jest website: Getting started with Jest.
While running npm test
on I was getting the following error:
FAIL src/sum.test.js
● Test suite failed to run
TypeError: environment.setup is not a function
at node_modules/jest-runner/build/run_test.js:112:23
sum.js
:
function sum(a, b){
return a+b;
}
module.exports = sum;
sum.test.js
:
const sum = require('./sum');
test('adding sum function', () => {
expect(sum(234,4)).toBe(238);
})
sum.js
and sum.test.js
are an exact copy of the example shown in Getting started with Jest.
package.json
:
{
name: jest-demo-test,
version: 0.1.0,
private: true,
dependencies: {
react: ^16.2.0,
react-dom: ^16.2.0,
react-scripts: 1.0.17
},
scripts: {
start: react-scripts start,
build: react-scripts build,
test: jest,
eject: react-scripts eject
},
devDependencies: {
jest: ^22.0.4
}
}
So, how can I get rid of TypeError: environment.setup is not a function
error?