挂起 Jenkins 构建的成功测试

时间:2021-03-02 16:26:38

标签: node.js jenkins continuous-integration continuous-deployment supertest

我是 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);
    });
});

这是詹金日志的截图:

Jenkin Log Image

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

Mocha 4 需要 --exit 标志才能在测试后终止。或者,您必须将应用配置为自行清理。

在测试脚本中我写了 ./node_modules/.bin/mocha ./test/test.js 而不是 ./node_modules/.bin/mocha ./test/test.js --exit