Node Assert section method

Assert (value[, message]) assert.ok(value[, message]) assert() is short for assert.ok() and can be used the same way. If the value of value istrueThen nothing will happen. If the value isfalseWill throw an error with the message message. Value. Equal (actual, expected[, message]) determines whether actual and expected values are equal(==) and when this is not value, a message error is thrown. Assert.deepequal (actual, Expected [, message]) deep means that enumerable attributes of child objects are also counted. Passes if both its property and its child property are equal. Otherwise an error is thrown. Assert. DeepStrictEqual (actual, Expected [, message]) determines whether the depth is strictly equal. assert.notDeepEqual(actual, expected[, message]) assert.notDeepStrictEqual(actual, expected[, message]) assert.notEqual(actual, expected[, message]) assert.notStrictEqual(actual, expected[, message]) assert.strictEqual(actual, expected[, message]) assert.throws(block[, error][, message])Copy the code


should.js

Understanding part, the basic writing is as follows:

.true (===)

true.should.be.true;Copy the code

.false (! = =)

false.should.be.false
(0).should.not.be.falseCopy the code

Reference documentation, https://unitjs.com/guide/should-js.html


mocha

The installation

NPM install mocha - gCopy the code

Reference documentation, http://www.ruanyifeng.com/blog/2015/12/a-mocha-tutorial-of-examples.html


karma

NPM install karma - DCopy the code

$karma init (next step will produce configuration file: karmap.conf.js after next step)

 1. Which testing framework do you want to use ? (mocha) 

2. Do you want to use Require.js ? (no) 

3. Do you want to capture any browsers automatically ? (Chrome) 

4. What is the location of your source and test files ? (test/**.js) 

5. Should any of the files included by the previous patterns be excluded ? (a)

6. Do you want Karma to watch all the files and run the tests on change ? (yes)

Refer to the article, https://blog.csdn.net/wknhsj1/article/details/79243385


Travis CI

The website https://travis-ci.org/

.travis.yml

Node Project Preparation

language: node_js
node_js:
  - "8"Copy the code

run

npm i
npm testCopy the code

Refer to the article, http://www.ruanyifeng.com/blog/2017/12/travis_ci_tutorial.html