0

In my Angular application test suite I have a test case doing the following:

it('test case with async operation', async(() => {
  // open modal

  // do some stuff

  fixture.whenStable().then(() => {
    // do some async stuff and close the modal

    // some expetations
  });
}));

Everything works fine except that when this test actually finishes executing, the modal is still open (the whenStable callback will execute just a bit later, closing the modal). This makes other test failing since the modal will still be open for a little while.

Note that the modal is not part of the fixture component, so I queried it using document.querySelector

Note that the test case is wrapped into async.

The problem is that I have to wait for an async operationg inside the modal, which forces me to use async and whenStable. For this purpose, I've also tried to use fakeAsync and tick instead of async, but that would give me the error error 1 timer(s) still in the queue.

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252

0 Answers0