In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
JavaScript code style check tool node jscs is how, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Node-jscs is a code style checking tool for JavaScript. It can be used in Node.js and browsers, using the following methods in browsers.
Methods used by node-jscs
Varchecker=newJscsStringChecker ()
Checker.registerDefaultRules ()
Checker.configure ({disallowMultipleVarDecl:true})
Varerrors=checker.checkString ('varx,y=1;')
Errors.getErrorList () .forEach (function (error) {
Console.log (errors.explainError (error))
})
Detect node-jscs
First of all, you need to install the nodejs development environment to detect nodejs. At present, the front-end unit tests only cover the logical content (environment) in js.
Unit testing
The front-end node.js uses jest for unit testing.
Install the jest environment
Install jest
Cdxxxx# goes to the root directory of the project file
Npmi# needs to be installed to the root directory of the project
When npmruntest# is installed in this way, you need to use this command to run jest
one
two
three
Install jest (2)
Npminstall-gyarn# installs yarn, which may cause permission problems and add sudo.
Yarn--version# verifies yarn
Cdxxxx# goes to the root directory of the project file
Yarnadd--devjest# installation jest# needs to be installed to the root directory of the project
Yarntest# runs all the tests of the project
Yarntestxxx# runs the project specified folder test
one
two
three
four
five
six
Unit test coverage
Use npmruntest
Npmruntest--coverage# can see the coverage on the terminal.
one
Use yarntest
Yarntest--coverage# can see the coverage on the terminal.
Yarnjest--coverage# can see the coverage on the terminal.
one
two
Coverage index
% stmts is statement coverage (statementcoverage): is every statement executed?
% Branch branch coverage (brabchcoverahe): is every if block executed?
% Funcs function coverage (functioncoverage): is every function called?
% Lines line coverage (linecoverage): is every line executed?
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.