Front-end test automation jest Lesson 3 command-line tool

Here Insert Picture Description

Ready condition

And code to create a directory of Section 1 tutorial basis to explain. If you have not read section 1 of the tutorial, please pay attention to me, to see the previous article in this series

This section of the tutorial mainly on jest some command-line tool to copy a section of the first code and runnpm run test
renderings:

Put these tips command, explain


Here are several commands you must own hands to try to be able to increase the impression that
focuses o talk about this command, you need to use with a git, you must submit the project to a local repository (the actual development, basic items are placed git repository so little effect), jest to determine which files are modified by the git add warehouses as follows:

  • git init Initialize git repository
  • git add . All files will be added to the staging area
  • git commit -m 'init' The submission of documents to the local repository

Below these is the configuration of the package.json

–watchAll

We are currently using -watchAll, monitoring all file changes
script configuration file packeage.json

"scripts": {
  "test": "jest --watchAll"
}

–watch

This -watchAll and press the o key after use, the effect is the same. After a time to re-test the modified file

"scripts": {
  "test": "jest --watch"
}

–init

Jest generate a base configuration file

–coverage

The details of test coverage information for the report output, generate test coverage
is generated in a project coveragefolder, open them index.htmlto see the details

This is more than a few commonly used, lies in the actual project these enough to use, jest of cli configuration files are many, but the actual development, we are in line with other scaffolding to achieve out of the box, a lot of configuration I have not used them, are interested, you can go to the official web document look https://jestjs.io/docs/en/cli

This section few, but the best are yourself to try and deepen their impression and understanding
the following section tutorial explains how to test asynchronous code in jest in

Never believe that he is a genius, then a simple matter best to try it yourself, do not have unrealistic expectations, encourage each other

I limited capacity, the article may be incorrect or inappropriate part, I hope you can point

No public concern, and I studied with the skills required front-end, front-end automated testing jest

No public concern, and I studied with the skills required front-end, front-end automated testing jestHere Insert Picture Description

Published 14 original articles · won praise 5 · views 10000 +

Guess you like

Origin blog.csdn.net/Jsoning/article/details/103964246