0

モーダル ウィンドウでいくつかのロジックを処理する Electron アプリケーションに取り組んでいます。これらのウィンドウは、非同期アクションが解決されるのを待ってから、自動的に閉じます。現在、Spectron と Jest を使用してこの動作をテストするのに苦労しています。ウィンドウのクローズをキャッチして別のテストに進む方法がないようです。

現在、私のコードは

it('doing its job', async () => {
  // awaits and expects that aren't related

  await app.client.click('button[data-role="close"]');
  await new Promise(r => setTimeout(r, 1000));
  expect(await client.getWindowCount()).toBe(1);
});

それは機能しますが、非常にアンチパターンだと思います。のようなことをする方法はあるのだろうか

it('doing its job', async () => {
  // awaits and expects that aren't related

  await app.client.click('button[data-role="close"]');
  await app.client.waitUntilWindowCloses(windowIndex);
  expect(await client.getWindowCount()).toBe(1);
});

どんな助けでも大歓迎です。

4

1 に答える 1