是否可以與摩卡同步調用測試用例?例如,我有下面的代碼: context('Context of test suite',() => {
it('test case name',() => {
//call expect() a few times
})
})
console.log('foo')
我要運行它,但我要保證foo將不被打印後,才測試用例已經執行,要
考慮下面的函數,用摩卡 function helloAfter100ms(){
setTimeout(function(){
console.log('hello');
},100)
}
測試代碼, describe('#helloAfter100ms()',function(){
it('console logs hello ONLY after 1
我的快遞服務器會引發一個錯誤,如果有參數缺失(例如,DB URI)。我想在摩卡測試它實際上拋出了錯誤,但我不知道如何讓摩卡能做到這一點。 if(!parameters.db) {
throw new Error('Please provide a db URI');
}
我有一個測試的設置是這樣的: it('Throws Error when no db URI provided
我有一個Express服務器,我正在使用Passport-local進行身份驗證。我有以下受保護的路線: app.post("/api/test", connect.ensureLoggedIn("/"), (req, res) => {
let test = new Test(req.body);
test
.save()
.then(data => {
re