What is the default test framework for ReactJS?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


What is the default test framework for ReactJS?



By using Create-React-App to scaffolding a new project, it will include default App.test.js with below content:


Create-React-App


App.test.js


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


yarn test



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?


npm run test


jest-cli


C-R-A



Below is the default package.json:


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"
}
}



UPDATES:



I've then execute the command npm install --save jest-cli to install the missing dependencies and try running the test again and hitting the below error instead:


npm install --save jest-cli


Determining test suites to run...
--watch is not supported without git/hg, please use --watchAll
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! testing@0.1.0 test: `react-scripts test --env=jsdom`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the testing@0.1.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived