Jest--painless JavaScript UnitTesting
Characteristics
- Strong Adaptability
- use Jasmine assertion by default
- the modular
- the extensible
- can be configured with
- sandbox-style and fast
- virtualized JS Environment, simulation browser
- running worker threads in parallel
- The default simulation framework
- automatically simulates all modules by default for easy testing of current code
Integrated Babel
- Necessity
- supports ES6 standard syntax
- support for react specific syntax
- Installing components
NPM Install--save-dev babel-jest Babel-polyfill
- Configure Babel
{
"presets": ["es2015", "react"]
}
Test change Code only
Jest–onlychanged or Jest-o
Manual simulation
Convention: Manual simulation files are placed under the "__mocks__" folder in the project root directory.
Enter test results
- command: Jest–json
- terminal output (as shown):
Note: If there is a mistake, the output error stack information is appended.
Generate Coverage Report
- command: Jest–coverage
- terminal output (as shown):
- Build Site file contents (as shown):Browse the site (as shown):
Note: The table of contents can also be accessed and browse the file content.
More content
- Jest Home
- git home
Nodejs and Reactjs Unit test tools--jest