diff --git a/projects/testing-library/src/lib/models.ts b/projects/testing-library/src/lib/models.ts index c095a5e..656b266 100644 --- a/projects/testing-library/src/lib/models.ts +++ b/projects/testing-library/src/lib/models.ts @@ -1,4 +1,13 @@ -import { Type, DebugElement, EventEmitter, Signal, InputSignalWithTransform } from '@angular/core'; +import { + Type, + DebugElement, + ModuleWithProviders, + EventEmitter, + EnvironmentProviders, + Provider, + Signal, + InputSignalWithTransform, +} from '@angular/core'; import { ComponentFixture, DeferBlockBehavior, DeferBlockState, TestBed } from '@angular/core/testing'; import { Routes } from '@angular/router'; import { BoundFunction, Queries, queries, Config as dtlConfig, PrettyDOMOptions } from '@testing-library/dom'; @@ -153,7 +162,7 @@ export interface RenderComponentOptions | unknown[])[]; /** * @description * A collection of providers needed to render the component via Dependency Injection, for example, injectable services or tokens. @@ -174,7 +183,7 @@ export interface RenderComponentOptions | ModuleWithProviders)[]; /** * @description * A collection of schemas needed to render the component. @@ -314,7 +323,7 @@ export interface RenderComponentOptions | any[])[]; + componentImports?: (Type | unknown[])[]; /** * @description * Queries to bind. Overrides the default set from DOM Testing Library unless merged. @@ -462,7 +471,7 @@ export interface RenderComponentOptions { component: Type; - providers: any[]; + providers: Provider[]; } // eslint-disable-next-line @typescript-eslint/no-empty-object-type @@ -496,7 +505,7 @@ export interface Config extends Pick, 'excludeCompon /** * Imports that are added to the imports */ - defaultImports: any[]; + defaultImports?: (Type | ModuleWithProviders)[]; /** * Set to `true` to use zoneless change detection. * This automatically adds `provideZonelessChangeDetection` to the default imports. diff --git a/projects/testing-library/src/lib/testing-library.ts b/projects/testing-library/src/lib/testing-library.ts index 5035220..535ef39 100644 --- a/projects/testing-library/src/lib/testing-library.ts +++ b/projects/testing-library/src/lib/testing-library.ts @@ -6,6 +6,7 @@ import { OnChanges, OutputRef, OutputRefSubscription, + Provider, SimpleChange, SimpleChanges, Type, @@ -436,7 +437,7 @@ function overrideComponentImports(sut: Type | string, imports: function overrideChildComponentProviders(componentOverrides: ComponentOverride[]) { if (componentOverrides) { for (const { component, providers } of componentOverrides) { - TestBed.overrideComponent(component, { set: { providers } }); + TestBed.overrideComponent(component, { set: { providers: providers as Provider[] } }); } } } @@ -499,7 +500,7 @@ function addAutoDeclarations( wrapper, }: Pick, 'declarations' | 'excludeComponentDeclaration' | 'wrapper'>, ) { - const nonStandaloneDeclarations = declarations?.filter((d) => !isStandalone(d)); + const nonStandaloneDeclarations = declarations.filter((d) => !isStandalone(d as Type)); if (typeof sut === 'string') { if (wrapper && isStandalone(wrapper)) { return nonStandaloneDeclarations;