import { equal } from 'assert'; import { get } from './server'; describe('Array', function () { describe('#indexOf()', function () { it('should return -1 when the value is not present', function () { equal([1, 2, 3].indexOf(4), -1); }); }); }); // 使用mocha对路径 "/ping" 进行单元测试 describe('Web', function () { it('/exece should return 404', () => { get('/exece').expect(404) .end((err) => { if (err) throw err }) }) it('/ping should return "pong"', function (done) { get('/ping') .expect('app-ping', 'pong') .expect('pong', done); }); it('/home', function (done) { get('/home').expect('home', done); }); });