本文共 810 字,大约阅读时间需要 2 分钟。
Mocha is a feature-rich JavaScript test framework running on and in the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases. Hosted on .
Install with globally:
$ npm install --global mocha
or as a development dependency for your project:
$ npm install --save-dev mocha
Mocha currently requires Node.js v6.x or newer.
$ npm install mocha$ mkdir test$ $EDITOR test/test.js # or open with your favorite editor
In your editor:
var assert = require('assert');describe('Array', function() { describe('#indexOf()', function() { it('should return -1 when the value is not present', function() { assert.equal([1,2,3].indexOf(4), -1); }); });});
转载地址:http://ocdvl.baihongyu.com/