テストの実行が完了した後に冗談は1秒を終了しませんでした。

ユニットテストを使用するときに問題が発生した冗談:

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

考えられる原因:データベース接続のテストは、テストが閉じていない終了します。

ソリューション:

···
import * as mongoose from 'mongoose';
···

describe('AppController (e2e)', () => {
     ···
    afterAll(async () => {
        mongoose.disconnect();
    });
})

おすすめ

転載: www.cnblogs.com/hl1223/p/11771258.html