test(core): update tests that were relying on implicit animations module (#59762)

We had some tests that were relying on the fact that the server module was importing animations implicitly.

PR Close #59762
This commit is contained in:
Kristiyan Kostadinov 2025-01-28 19:35:17 +01:00 committed by Alex Rickabaugh
parent fc5d187da5
commit ea2ea5e65b
6 changed files with 16 additions and 7 deletions

View file

@ -38,6 +38,7 @@ import {getLView} from '@angular/core/src/render3/state';
import {ngDevModeResetPerfCounters} from '@angular/core/src/util/ng_dev_mode';
import {fakeAsync, flushMicrotasks, TestBed} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {expectPerfCounters} from '@angular/private/testing';
describe('acceptance integration tests', () => {
@ -2889,6 +2890,7 @@ describe('acceptance integration tests', () => {
TestBed.configureTestingModule({
declarations: [Cmp, AnimationComp],
imports: [NoopAnimationsModule],
providers: [{provide: AnimationDriver, useClass: MockAnimationDriver}],
});
const fixture = TestBed.createComponent(Cmp);
@ -2979,6 +2981,7 @@ describe('acceptance integration tests', () => {
TestBed.configureTestingModule({
declarations: [Cmp, InnerComp],
imports: [NoopAnimationsModule],
providers: [{provide: AnimationDriver, useClass: MockAnimationDriver}],
});
const fixture = TestBed.createComponent(Cmp);

View file

@ -10,6 +10,7 @@ import {CommonModule} from '@angular/common';
import {Component, Directive, EventEmitter, Input, Output, ViewContainerRef} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {By, DomSanitizer, SafeUrl} from '@angular/platform-browser';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
describe('property bindings', () => {
it('should support bindings to properties', () => {
@ -689,7 +690,10 @@ describe('property bindings', () => {
})
class App {}
TestBed.configureTestingModule({declarations: [App, MyDir, MyComp]});
TestBed.configureTestingModule({
declarations: [App, MyDir, MyComp],
imports: [NoopAnimationsModule],
});
expect(() => {
const fixture = TestBed.createComponent(App);

View file

@ -372,12 +372,8 @@ describe('Angular with zoneless enabled', () => {
expect(host.innerHTML).toEqual('<dynamic-cmp>binding</dynamic-cmp>');
const component2 = createComponent(DynamicCmp, {environmentInjector});
// TODO(atscott): Only needed because renderFactory will not run if ApplicationRef has no
// views. This should likely be fixed in ApplicationRef
appRef.attachView(component2.hostView);
appRef.detachView(component.hostView);
// DOM is not synchronously removed because change detection hasn't run
expect(host.innerHTML).toEqual('<dynamic-cmp>binding</dynamic-cmp>');
expect(isStable()).toBe(false);
await whenStable();
expect(host.innerHTML).toEqual('');

View file

@ -45,6 +45,7 @@ import {isTextNode} from '@angular/platform-browser/testing/src/browser_util';
import {expect} from '@angular/platform-browser/testing/src/matchers';
import {MockResourceLoader} from './resource_loader_mock';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
const TEST_COMPILER_PROVIDERS: Provider[] = [
{provide: ResourceLoader, useClass: MockResourceLoader, deps: []},
@ -110,6 +111,7 @@ const TEST_COMPILER_PROVIDERS: Provider[] = [
beforeEach(() => {
TestBed.configureCompiler({providers: TEST_COMPILER_PROVIDERS});
TestBed.configureTestingModule({
imports: [NoopAnimationsModule],
declarations: [
TestData,
TestDirective,

View file

@ -47,6 +47,7 @@ ts_library(
"//packages/localize",
"//packages/localize/init",
"//packages/platform-browser",
"//packages/platform-browser/animations",
"//packages/platform-server",
"//packages/private/testing",
"//packages/router",

View file

@ -66,6 +66,7 @@ import {provideRouter, RouterOutlet, Routes} from '@angular/router';
import {Observable} from 'rxjs';
import {renderApplication, SERVER_CONTEXT} from '../src/utils';
import {BrowserAnimationsModule, provideAnimations} from '@angular/platform-browser/animations';
const APP_CONFIG: ApplicationConfig = {
providers: [provideServerRendering()],
@ -390,11 +391,13 @@ function createMyAnimationApp(standalone: boolean) {
}
const MyAnimationApp = createMyAnimationApp(false);
const MyAnimationAppStandalone = getStandaloneBootstrapFn(createMyAnimationApp(true));
const MyAnimationAppStandalone = getStandaloneBootstrapFn(createMyAnimationApp(true), [
provideAnimations(),
]);
@NgModule({
declarations: [MyAnimationApp],
imports: [BrowserModule, ServerModule],
imports: [BrowserModule, BrowserAnimationsModule, ServerModule],
bootstrap: [MyAnimationApp],
})
class AnimationServerModule {}