Skip to main content

Testing Modules with BrowserAnimationsModule

By default, ng-mocks replaces BrowserAnimationsModule with NoopAnimationsModule.

However, it can be changed via MockBuilder or ngMocks.guts when NoopAnimationsModule isn't a solution.

MockBuilder#

// No animations at allMockBuilder(MyComponent, MyModule).exclude(BrowserAnimationsModule);
// Mock BrowserAnimationsModuleMockBuilder(MyComponent, MyModule).mock(BrowserAnimationsModule);
// Keep BrowserAnimationsModule to test animations.MockBuilder(MyComponent, MyModule).keep(BrowserAnimationsModule);

ngMocks.guts#

// No animations at allngMocks.guts(MyComponent, MyModule, BrowserAnimationsModule);
// Mock BrowserAnimationsModulengMocks.guts(MyComponent, [MyModule, BrowserAnimationsModule]);
// Keep BrowserAnimationsModule to test animations.ngMocks.guts([MyComponent, BrowserAnimationsModule], MyModule);

fakeAsync#

A kept / mock BrowserAnimationsModule causes issues with fakeAsync. Please open an issue on github, if you have a case where NoopAnimationsModule isn't a solution.