Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Updated testing-libary.ts
Adresses the breaking change which comes trough angular/angular#48114
  • Loading branch information
TrustNoOneElse authored Jan 12, 2023
commit ac523f548c33a12d716f02677e2ac0858a814597
8 changes: 4 additions & 4 deletions projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
OnChanges,
SimpleChanges,
ApplicationInitStatus,
ɵisStandalone,
isStandalone,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if this also works with Angular v15.0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does not work with Angular v15.0 since they introduced this breaking change first at v15.1.

} from '@angular/core';
import { ComponentFixture, TestBed, tick } from '@angular/core/testing';
import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations';
Expand Down Expand Up @@ -321,7 +321,7 @@ function setComponentInputs<SutType>(

function overrideComponentImports<SutType>(sut: Type<SutType> | string, imports: (Type<any> | any[])[] | undefined) {
if (imports) {
if (typeof sut === 'function' && ɵisStandalone(sut)) {
if (typeof sut === 'function' && isStandalone(sut)) {
TestBed.overrideComponent(sut, { set: { imports } });
} else {
throw new Error(
Expand Down Expand Up @@ -369,7 +369,7 @@ function addAutoDeclarations<SutType>(
return [...declarations, wrapper];
}

const components = () => (excludeComponentDeclaration || ɵisStandalone(sut) ? [] : [sut]);
const components = () => (excludeComponentDeclaration || isStandalone(sut) ? [] : [sut]);
return [...declarations, ...components()];
}

Expand All @@ -384,7 +384,7 @@ function addAutoImports<SutType>(
};

const routing = () => (routes ? [RouterTestingModule.withRoutes(routes)] : []);
const components = () => (typeof sut !== 'string' && ɵisStandalone(sut) ? [sut] : []);
const components = () => (typeof sut !== 'string' && isStandalone(sut) ? [sut] : []);
return [...imports, ...components(), ...animations(), ...routing()];
}

Expand Down