Open2

jestのteardownでの非同期処理

ratmieratmie

teardownで非同期処理したい場合に少し注意

処理が1つのときはreturnで返せば良い

afterAll(() => {
  return something();
});

複数ある場合はasyncにしてcallbackで終了を明示する

afterAll(async (done) => {
  await somethingA();
  await somethingB();
  done();
});
ratmieratmie

Sequelizeを使うとうまく行ってなさそう。

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.

sequelize.close()だけだとうまく行かない?