使用mochajs进行js测试

xiaoxiao2021-02-28  81

mochajs是一款流行的nodejs测试工具。git地址:https://github.com/mochajs/mocha。

npm install mocha --save-dev安装。

在工具目录下创建test目录。

在test目录下创建test.js(mocha会自动寻找test目录下所有js文件),编写测试代码:

var assert = require('assert'); describe('calculate', () => { it('plus', () => { assert.ok( 1 + 1 === 2); }) }) 这里使用的是assert作判断,当然你也可以使用should或者其他的工具。

转载请注明原文地址: https://www.6miu.com/read-77034.html

最新回复(0)