Skip to content

Commit

Permalink
fix(material/schematics): remove NoopAnimationsModule from generated …
Browse files Browse the repository at this point in the history
…tests (#30562)

Removes the `NoopAnimationsModule` from the tests generated by `ng generate` since it requires the animations module to be installed.

Fixes #30560.
  • Loading branch information
crisbeto authored Feb 28, 2025
1 parent fc46997 commit 31c4dad
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('<%= classify(name) %>Component', () => {
TestBed.configureTestingModule({
declarations: [<%= classify(name) %>Component],
imports: [DragDropModule]
}).compileComponents();
});
}));<% } %>

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';<% if(!standalone) { %>
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %>
import { ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
Expand All @@ -11,23 +10,21 @@ import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.compone

describe('<%= classify(name) %>Component', () => {
let component: <%= classify(name) %>Component;
let fixture: ComponentFixture<<%= classify(name) %>Component>;
let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %>

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({<% if(standalone) { %>
imports: [NoopAnimationsModule]<% } else { %>
TestBed.configureTestingModule({
declarations: [<%= classify(name) %>Component],
imports: [
NoopAnimationsModule,
ReactiveFormsModule,
MatButtonModule,
MatCardModule,
MatInputModule,
MatRadioModule,
MatSelectModule,
]<% } %>
}).compileComponents();
}));
]
});
}));<% } %>

beforeEach(() => {
fixture = TestBed.createComponent(<%= classify(name) %>Component);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';<% if(!standalone) { %>
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %>
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatGridListModule } from '@angular/material/grid-list';
Expand All @@ -10,22 +9,20 @@ import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.compone

describe('<%= classify(name) %>Component', () => {
let component: <%= classify(name) %>Component;
let fixture: ComponentFixture<<%= classify(name) %>Component>;
let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %>

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({<% if(standalone) { %>
imports: [NoopAnimationsModule]<% } else { %>
TestBed.configureTestingModule({
declarations: [<%= classify(name) %>Component],
imports: [
NoopAnimationsModule,
MatButtonModule,
MatCardModule,
MatGridListModule,
MatIconModule,
MatMenuModule,
]<% } %>
}).compileComponents();
}));
]
});
}));<% } %>

beforeEach(() => {
fixture = TestBed.createComponent(<%= classify(name) %>Component);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';<% if(!standalone) { %>
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %>
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatListModule } from '@angular/material/list';
Expand All @@ -10,22 +9,20 @@ import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.compone

describe('<%= classify(name) %>Component', () => {
let component: <%= classify(name) %>Component;
let fixture: ComponentFixture<<%= classify(name) %>Component>;
let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(standalone) { %>

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({<% if(standalone) { %>
imports: [NoopAnimationsModule]<% } else { %>
TestBed.configureTestingModule({
declarations: [<%= classify(name) %>Component],
imports: [
NoopAnimationsModule,
MatButtonModule,
MatIconModule,
MatListModule,
MatSidenavModule,
MatToolbarModule,
]<% } %>
}).compileComponents();
}));
]
});
}));<% } %>

beforeEach(() => {
fixture = TestBed.createComponent(<%= classify(name) %>Component);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';<% if(!standalone) { %>
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %>
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';<% } %>
Expand All @@ -8,20 +7,18 @@ import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.compone

describe('<%= classify(name) %>Component', () => {
let component: <%= classify(name) %>Component;
let fixture: ComponentFixture<<%= classify(name) %>Component>;
let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %>

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({<% if(standalone) { %>
imports: [NoopAnimationsModule]<% } else { %>
TestBed.configureTestingModule({
declarations: [<%= classify(name) %>Component],
imports: [
NoopAnimationsModule,
MatPaginatorModule,
MatSortModule,
MatTableModule,
]<% } %>
}).compileComponents();
}));
]
});
}));<% } %>

beforeEach(() => {
fixture = TestBed.createComponent(<%= classify(name) %>Component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('<%= classify(name) %>Component', () => {
MatIconModule,
MatTreeModule,
]
}).compileComponents();
});
}));<% } %>

beforeEach(() => {
Expand Down

0 comments on commit 31c4dad

Please sign in to comment.