By using Create-React-App
to scaffolding a new project, it will include default App.test.js
with below content:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
//expect(div.innerHTML).toContain('Hi There!');
ReactDOM.unmountComponentAtNode(div);
});
I've tried to run command yarn test
, below is the response i got
Error: Cannot find module '/Users/isaaclem/Code/ReactJS/testing/node_modules/jest-cli'
And if I try npm run test
instead, I'm hitting same error too, which saying couldnt find jest-cli
. Is there any reason where C-R-A
gives us a default test file but not including the necessary framework/module?
Below is the default package.json
:
{
"name": "testing",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Aucun commentaire:
Enregistrer un commentaire