Skip to content

Commit

Permalink
docs(BrowserAnimationsModule): an example how to write tests #7466
Browse files Browse the repository at this point in the history
  • Loading branch information
satanTime committed Nov 18, 2023
1 parent b9651be commit 9c44180
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/articles/troubleshooting/browser-animations-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,20 @@ ngMocks.guts(MyComponent, MyModule, BrowserAnimationsModule);
A kept / mock `BrowserAnimationsModule` causes issues with `fakeAsync`.
Please open an issue on [GitHub](/~https://github.com/help-me-mom/ng-mocks/issues),
if you have a case where `NoopAnimationsModule` isn't a solution.

## Writing tests

In contrast to regular tests, you need to await `fixture.whenStable()` after `fixture.detectChanges()`
to render noop animations correctly.

Because `fixture.whenStable()` returns a promise, you need to make the whole test `async`.

```ts
it('should see all elements', async () => { // <-- async
// ... configuration
fixture.detectChanges(); // <-- detecting changes
await fixture.whenStable(); // <-- awaiting animations
// ... assertion
});
```
:::

0 comments on commit 9c44180

Please sign in to comment.