Skip to content

Use exhaustive checkNoChanges by default #31069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import {CdkVirtualScrollViewport, ScrollingModule} from '@angular/cdk/scrolling';
import {Component, Input, ViewChild, ViewEncapsulation} from '@angular/core';
import {
Component,
Input,
provideCheckNoChangesConfig,
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import {ComponentFixture, TestBed, fakeAsync, flush, waitForAsync} from '@angular/core/testing';
import {ScrollingModule as ExperimentalScrollingModule} from './scrolling-module';

Expand All @@ -11,6 +17,7 @@ describe('CdkVirtualScrollViewport', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [ScrollingModule, ExperimentalScrollingModule, AutoSizeVirtualScroll],
});
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {MatCheckboxHarness} from '@angular/material/checkbox/testing';
import {CheckboxHarnessExample} from './checkbox-harness-example';
import {provideCheckNoChangesConfig} from '@angular/core';

describe('CheckboxHarnessExample', () => {
let fixture: ComponentFixture<CheckboxHarnessExample>;
let loader: HarnessLoader;

beforeEach(() => {
TestBed.configureTestingModule({providers: [provideCheckNoChangesConfig({exhaustive: false})]});
fixture = TestBed.createComponent(CheckboxHarnessExample);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
Expand Down
11 changes: 10 additions & 1 deletion src/material/button-toggle/button-toggle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import {dispatchMouseEvent} from '@angular/cdk/testing/private';
import {Component, DebugElement, QueryList, ViewChild, ViewChildren} from '@angular/core';
import {
Component,
DebugElement,
provideCheckNoChangesConfig,
QueryList,
ViewChild,
ViewChildren,
} from '@angular/core';
import {ComponentFixture, TestBed, fakeAsync, flush, tick} from '@angular/core/testing';
import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/forms';
import {By} from '@angular/platform-browser';
Expand All @@ -14,6 +21,7 @@ import {
describe('MatButtonToggle with forms', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatButtonToggleModule,
FormsModule,
Expand Down Expand Up @@ -327,6 +335,7 @@ describe('MatButtonToggle with forms', () => {
describe('MatButtonToggle without forms', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatButtonToggleModule,
ButtonTogglesInsideButtonToggleGroup,
Expand Down
3 changes: 2 additions & 1 deletion src/material/checkbox/testing/checkbox-harness.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, signal} from '@angular/core';
import {Component, provideCheckNoChangesConfig, signal} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
Expand All @@ -12,6 +12,7 @@ describe('MatCheckboxHarness', () => {

beforeEach(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [MatCheckboxModule, ReactiveFormsModule, CheckboxHarnessTest],
});

Expand Down
8 changes: 6 additions & 2 deletions src/material/datepicker/calendar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
dispatchKeyboardEvent,
dispatchMouseEvent,
} from '@angular/cdk/testing/private';
import {Component} from '@angular/core';
import {Component, provideCheckNoChangesConfig} from '@angular/core';
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
import {DateAdapter, MatNativeDateModule} from '../core';
import {By} from '@angular/platform-browser';
Expand All @@ -21,7 +21,11 @@ describe('MatCalendar', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatNativeDateModule, MatDatepickerModule],
providers: [MatDatepickerIntl, {provide: Directionality, useFactory: () => ({value: 'ltr'})}],
providers: [
MatDatepickerIntl,
{provide: Directionality, useFactory: () => ({value: 'ltr'})},
provideCheckNoChangesConfig({exhaustive: false}),
],
declarations: [
// Test components.
StandardCalendar,
Expand Down
12 changes: 11 additions & 1 deletion src/material/datepicker/date-range-input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ import {Direction, Directionality} from '@angular/cdk/bidi';
import {BACKSPACE, LEFT_ARROW, RIGHT_ARROW} from '@angular/cdk/keycodes';
import {OverlayContainer} from '@angular/cdk/overlay';
import {dispatchFakeEvent, dispatchKeyboardEvent} from '@angular/cdk/testing/private';
import {Component, Directive, ElementRef, Provider, signal, Type, ViewChild} from '@angular/core';
import {
Component,
Directive,
ElementRef,
provideCheckNoChangesConfig,
Provider,
signal,
Type,
ViewChild,
} from '@angular/core';
import {ComponentFixture, fakeAsync, flush, TestBed, tick} from '@angular/core/testing';
import {
FormControl,
Expand Down Expand Up @@ -37,6 +46,7 @@ describe('MatDateRangeInput', () => {
component,
],
providers: [
provideCheckNoChangesConfig({exhaustive: false}),
...providers,
{provide: MATERIAL_ANIMATIONS, useValue: {animationsDisabled: true}},
],
Expand Down
9 changes: 8 additions & 1 deletion src/material/expansion/accordion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import {
dispatchEvent,
dispatchKeyboardEvent,
} from '@angular/cdk/testing/private';
import {Component, QueryList, ViewChild, ViewChildren} from '@angular/core';
import {
Component,
provideCheckNoChangesConfig,
QueryList,
ViewChild,
ViewChildren,
} from '@angular/core';
import {TestBed, waitForAsync} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {
Expand All @@ -20,6 +26,7 @@ describe('MatAccordion', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatExpansionModule,
AccordionWithHideToggle,
Expand Down
3 changes: 3 additions & 0 deletions src/material/list/selection-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ChangeDetectionStrategy,
Component,
DebugElement,
provideCheckNoChangesConfig,
QueryList,
ViewChildren,
} from '@angular/core';
Expand Down Expand Up @@ -44,6 +45,7 @@ describe('MatSelectionList without forms', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatListModule,
SelectionListWithListOptions,
Expand Down Expand Up @@ -1277,6 +1279,7 @@ describe('MatSelectionList without forms', () => {
describe('MatSelectionList with forms', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatListModule,
FormsModule,
Expand Down
2 changes: 2 additions & 0 deletions src/material/menu/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Input,
OnDestroy,
Output,
provideCheckNoChangesConfig,
Provider,
QueryList,
TemplateRef,
Expand Down Expand Up @@ -68,6 +69,7 @@ describe('MatMenu', () => {
): ComponentFixture<T> {
TestBed.configureTestingModule({
providers: [
provideCheckNoChangesConfig({exhaustive: false}),
...providers,
{provide: MATERIAL_ANIMATIONS, useValue: {animationsDisabled: true}},
],
Expand Down
3 changes: 2 additions & 1 deletion src/material/radio/radio.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {dispatchFakeEvent} from '@angular/cdk/testing/private';
import {Component, DebugElement, ViewChild} from '@angular/core';
import {Component, DebugElement, provideCheckNoChangesConfig, ViewChild} from '@angular/core';
import {ComponentFixture, TestBed, fakeAsync, tick, waitForAsync} from '@angular/core/testing';
import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/forms';
import {By} from '@angular/platform-browser';
Expand All @@ -14,6 +14,7 @@ import {
describe('MatRadio', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatRadioModule,
FormsModule,
Expand Down
2 changes: 2 additions & 0 deletions src/material/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
ViewChild,
ViewChildren,
inject,
provideCheckNoChangesConfig,
} from '@angular/core';
import {
ComponentFixture,
Expand Down Expand Up @@ -96,6 +97,7 @@ describe('MatSelect', () => {
OverlayModule,
],
providers: [
provideCheckNoChangesConfig({exhaustive: false}),
{provide: MATERIAL_ANIMATIONS, useValue: {animationsDisabled: true}},
{provide: Directionality, useFactory: () => (dir = {value: 'ltr', change: EMPTY})},
{
Expand Down
14 changes: 12 additions & 2 deletions src/material/sidenav/drawer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import {
dispatchEvent,
dispatchKeyboardEvent,
} from '@angular/cdk/testing/private';
import {Component, ElementRef, ErrorHandler, ViewChild} from '@angular/core';
import {
Component,
ElementRef,
ErrorHandler,
provideCheckNoChangesConfig,
ViewChild,
} from '@angular/core';
import {
ComponentFixture,
TestBed,
Expand All @@ -24,7 +30,10 @@ import {MATERIAL_ANIMATIONS} from '../core';
describe('MatDrawer', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [{provide: MATERIAL_ANIMATIONS, useValue: {animationsDisabled: true}}],
providers: [
{provide: MATERIAL_ANIMATIONS, useValue: {animationsDisabled: true}},
provideCheckNoChangesConfig({exhaustive: false}),
],
imports: [
MatSidenavModule,
A11yModule,
Expand Down Expand Up @@ -891,6 +900,7 @@ describe('MatDrawer', () => {
describe('MatDrawerContainer', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatSidenavModule,
A11yModule,
Expand Down
3 changes: 2 additions & 1 deletion src/material/sidenav/sidenav.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Component, ViewChild} from '@angular/core';
import {Component, provideCheckNoChangesConfig, ViewChild} from '@angular/core';
import {TestBed, fakeAsync, tick, waitForAsync} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {MatSidenav, MatSidenavContainer, MatSidenavModule} from './index';

describe('MatSidenav', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
imports: [
MatSidenavModule,
SidenavWithFixedPosition,
Expand Down
5 changes: 4 additions & 1 deletion src/material/sidenav/testing/sidenav-harness.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, signal} from '@angular/core';
import {Component, provideCheckNoChangesConfig, signal} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {HarnessLoader, parallel} from '@angular/cdk/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
Expand All @@ -16,6 +16,9 @@ describe('MatSidenavHarness', () => {
let loader: HarnessLoader;

beforeEach(() => {
TestBed.configureTestingModule({
providers: [provideCheckNoChangesConfig({exhaustive: false})],
});
fixture = TestBed.createComponent(DrawerHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
Expand Down
2 changes: 2 additions & 0 deletions src/material/stepper/stepper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
ViewChildren,
ViewEncapsulation,
inject,
provideCheckNoChangesConfig,
signal,
} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
Expand Down Expand Up @@ -1829,6 +1830,7 @@ function createComponent<T>(
TestBed.configureTestingModule({
imports: [MatStepperModule, ReactiveFormsModule, ...imports],
providers: [
provideCheckNoChangesConfig({exhaustive: false}),
{provide: Directionality, useFactory: () => dir},
{provide: MATERIAL_ANIMATIONS, useValue: {animationsDisabled: true}},
...providers,
Expand Down
9 changes: 8 additions & 1 deletion src/material/tabs/tab-nav-bar/tab-nav-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import {
dispatchKeyboardEvent,
dispatchMouseEvent,
} from '@angular/cdk/testing/private';
import {Component, QueryList, ViewChild, ViewChildren} from '@angular/core';
import {
Component,
provideCheckNoChangesConfig,
QueryList,
ViewChild,
ViewChildren,
} from '@angular/core';
import {ComponentFixture, TestBed, fakeAsync, tick, waitForAsync} from '@angular/core/testing';
import {MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions} from '../../core';
import {By} from '@angular/platform-browser';
Expand All @@ -32,6 +38,7 @@ describe('MatTabNavBar', () => {
TabBarWithInactiveTabsOnInit,
],
providers: [
provideCheckNoChangesConfig({exhaustive: false}),
{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useFactory: () => globalRippleOptions},
{provide: Directionality, useFactory: () => ({value: dir, change: dirChange})},
],
Expand Down
14 changes: 2 additions & 12 deletions test/angular-test.init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,12 @@ import 'zone.js';
import 'zone.js/testing';
import 'reflect-metadata';

import {ErrorHandler, NgModule, provideZonelessChangeDetection} from '@angular/core';
import {NgModule, provideCheckNoChangesConfig, provideZonelessChangeDetection} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {BrowserTestingModule, platformBrowserTesting} from '@angular/platform-browser/testing';

@NgModule({
providers: [
provideZonelessChangeDetection(),
{
provide: ErrorHandler,
useValue: {
handleError: (e: any) => {
throw e;
},
},
},
],
providers: [provideZonelessChangeDetection(), provideCheckNoChangesConfig({exhaustive: true})],
})
export class TestModule {}

Expand Down
Loading