0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【firestore + Jest】Jest did not exit one second after the test run has completed の対処法

Last updated at Posted at 2022-10-06

自分の環境

jest: 28.1.3
firebase: 9.8.4

原因

非同期処理が正しく終了していない
(自分の場合、非同期処理には全てawaitを付けているのでこれが原因ではありませんでした..)

とはいうものの非同期処理はawaitちゃんとつけているのに...

これ本当に悩みました。非同期処理は全てawaitを付けているのに何故エラーメッセージが消えないのかと。

答えありました。
GitHub Actions と Firebase を使用すると、テストの実行が完了してから 1 秒後に Jest が終了しませんでした。

テスト終了後にfirebaseとのリソースを切断する必要がある

下記のコードでfirebaseのリソースを解放しましょう!
【firebase v9 の場合】

describe("firestore test v9", ()=>{
    afterAll(() => {
        //リソース解放
        deleteApp(app);
    });
    test("何かしらのテスト", ()=>{
        //中身
    });
})

【firebase v8 の場合】

describe("firestore test v8", ()=>{
    afterAll(() => {
      //リソース解放
      firebase.app().delete();
    });
    test("何かしらのテスト", ()=>{
        //中身
    });
})
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?