Solve foreign module Download problem:
- FQ
- Switch Source: NRM
NPM Install Nrm-g
NRM ls View usage source
NRM use CNPM switch source to CNPM
Automated Test Framework Mocha (Mocha official website) KarmaAutomated testing for large projects without frequent changes, small function iterations are relatively fast and are not recommended to use
- Yarn Init-y
- NPM Install--global Mocha Global Installation Mocha
- Create a new test folder to store the automated test code
- The Const ASSERT = require ("Assert") in the JS code under the test folder
- Input Mocha will automatically test all programs under the test folder
Test async needs to write a done to the parameter, and then callMOCHA-T 5000 Asynchronous time-out is 5 seconds
Automated testing facilitates QA but increases front-end public work chai (assertion library) Search Chai There are 3 kinds of syntax
- NPM Install Chai--save
Automated Test Framework Mocha* math.jsmodule.exports = { add: function(a, b){ return Number(a, 10) + Number(b, 10); }, minus: function(a, b){ return Number(a, 10) - Number(b, 10); }, multiply: function(a, b){ return a * b; }, devision: function(a, b){ return a / b; }}
* Math.test.js//const assert = require ("assert")//Assert Const CHAI = require ("Chai")//Assert library const MATH = r Equire (".. /math.js ") chai.should (); Chai a syntax describe ("I'm going to test the Math module", () = {//describe is used to describe what it does ("Test Add Method", () = {//it description and true test code/*a Ssert.equal (Math.add (1, 2), 3)//equal represent equality assert.equal (Math.add ( -1, 2), 1) assert.equal (Math.add ("1", 2), 3) */Math.add (1, 2). Should.equal (3)}), it ("Test minus Method", () = {//it description and true test code/*assert.equal (MA Th.minus (1, 2),-1)//equal means equal assert.equal (Math.minus ( -1, 2), 3) assert.equal (Math.minus ("1", "2"),-1) Assert.equal (typeof Math.minus ("1", "2"), ' number ') */Math.minus (1, 2). Should.equal ( -1)}), it ("Test 2 seconds of , the multiplication is good ", (done) = {SetTimeout () {/*assert.equal (Math.multiply (5, 3), +) */M Ath.multiply (5, 2). Should.equal (Ten) Done ()})})
node_5/websocke/socket.io/solve foreign module download problem/mocha/chai (Assertion library)