0
私は単体テストに「モカ」と「チャイ」を使用しようとしていますが、テスト結果に問題があります。 ご覧ください。mocha + chaiによるユニットテストは常に成功
UnitTest.spec.ts
import PostgresService from "../src/Services/PostgresService"
import {expect} from "chai"
import 'mocha'
describe('Postgres Override Test function',() => {
it('should return any number but not zero', async() => {
let client = new PostgresService();
let result = await client.getLatestCMD("Servo");
try{
console.log("Type : " + typeof(result));
console.log("Value : " + result.rows[0].id);
expect(result.rows[0].id).to.equal(0)
}catch(error){
}
})
})
try catchブロックを削除してください – Liroy
@ LiroyLeshed.comそれは仕事です!しかし、なぜ? – kosterz
多くのユニットテストフレームワークは、例外をスローすることによってエラーを示します。あなたが静かに例外をキャッチすると、シグナルメカニズムを効果的に無効にします。 –