当我在我的项目中运行mocha测试时,它不能在测试后终止
我正在使用摩卡进行测试。
这是我的测试用例。
const mysql_service = require('../../router/mysql_service')
const chai = require('chai')
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('mysql_service', function () {
this.timeout(20000)
it('#qryInterconnectionStocks', function (done) {
mysql_service.qryInterconnectionStocks(20)
.then(function(result) {
expect(result).not.to.be.null
expect(Array.isArray(result)).to.be.true
// console.log(result)
done()
},function(err) {
console.log(err)
expect(err).to.be.null
done(err)
})
})
})
首先,我运行测试命令
mocha test/**/*.js
它成功了,但终端不退出。
回答如下:您应该将--exit
标志添加到mocha
命令以使其退出,请参阅breaking changes。