问题描述
我是 Jenkins 的新手,有 Supertest 和 Mocha。我正在运行一个测试脚本并在 Jenkins 中构建一个脚本。我的测试成功了,但 Build 挂了。
supertest npm 的测试脚本:
var request = require('supertest');
var app = require('../index.js');
describe('GET /',function() {
it('Respond with hello world',function(done) {
//navigate to root and check the the response is "hello world"
request(app).get('/').expect({
status : true,message : 'hello world'
},done);
});
});
这是詹金日志的截图:
有人可以帮忙吗?
解决方法
Mocha 4 需要 --exit
标志才能在测试后终止。或者,您必须将应用配置为自行清理。
在测试脚本中我写了 ./node_modules/.bin/mocha ./test/test.js
而不是 ./node_modules/.bin/mocha ./test/test.js --exit