Nodejs and Reactjs Unit test tools--jest

Source: Internet
Author: User


Jest--painless JavaScript UnitTesting

Characteristics
    1. Strong Adaptability
      1. use Jasmine assertion by default
      2. the modular
      3. the extensible
      4. can be configured with
    2. sandbox-style and fast
      1. virtualized JS Environment, simulation browser
      2. running worker threads in parallel
    3. The default simulation framework
      1. automatically simulates all modules by default for easy testing of current code
Integrated Babel
    1. Necessity
      1. supports ES6 standard syntax
      2. support for react specific syntax
    2. Installing components

NPM Install--save-dev babel-jest Babel-polyfill

    1. 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
    1. command: Jest–json
    2. terminal output (as shown):

      Note: If there is a mistake, the output error stack information is appended.

Generate Coverage Report
    1. command: Jest–coverage
    2. terminal output (as shown):

    3. 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
    1. Jest Home
    2. git home

Nodejs and Reactjs Unit test tools--jest

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.