Skip to content

Commit bff8acb

Browse files
committed
feat: rename ɵcomponentImports to componentImports
BREAKING CHANGE: The render property ɵcomponentImports is not experimental anymore, and is renamed to componentImports BEFORE: render(ParentComponent, { ɵcomponentImports: [ChildComponent], }); AFTER: render(ParentComponent, { componentImports: [ChildComponent], });
1 parent 71184b7 commit bff8acb

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

projects/testing-library/src/lib/models.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,12 @@ export interface RenderComponentOptions<ComponentType, Q extends Queries = typeo
195195
*
196196
* @example
197197
* const component = await render(AppComponent, {
198-
* ɵcomponentImports: [
198+
* componentImports: [
199199
* MockChildComponent
200200
* ]
201201
* })
202-
*
203-
* @experimental
204202
*/
205-
ɵcomponentImports?: (Type<any> | any[])[];
203+
componentImports?: (Type<any> | any[])[];
206204
/**
207205
* @description
208206
* Queries to bind. Overrides the default set from DOM Testing Library unless merged.

projects/testing-library/src/lib/testing-library.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function render<SutType, WrapperType = SutType>(
5555
wrapper = WrapperComponent as Type<WrapperType>,
5656
componentProperties = {},
5757
componentProviders = [],
58-
ɵcomponentImports: componentImports,
58+
componentImports: componentImports,
5959
excludeComponentDeclaration = false,
6060
routes = [],
6161
removeAngularAttributes = false,

projects/testing-library/tests/render.spec.ts

+21-21
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { render, fireEvent, screen } from '../src/public_api';
1919
<button>button</button>
2020
`,
2121
})
22-
class FixtureComponent { }
22+
class FixtureComponent {}
2323

2424
test('creates queries and events', async () => {
2525
const view = await render(FixtureComponent);
@@ -50,46 +50,46 @@ describe('standalone', () => {
5050

5151
describe('standalone with child', () => {
5252
@Component({
53-
selector: 'child-fixture',
53+
selector: 'atl-child-fixture',
5454
template: `<span>A child fixture</span>`,
5555
standalone: true,
5656
})
57-
class ChildFixture { }
57+
class ChildFixtureComponent {}
5858

5959
@Component({
60-
selector: 'child-fixture',
60+
selector: 'atl-child-fixture',
6161
template: `<span>A mock child fixture</span>`,
6262
standalone: true,
6363
})
64-
class MockChildFixture { }
64+
class MockChildFixtureComponent {}
6565

6666
@Component({
67-
selector: 'parent-fixture',
67+
selector: 'atl-parent-fixture',
6868
template: `<h1>Parent fixture</h1>
69-
<div><child-fixture></child-fixture></div> `,
69+
<div><atl-child-fixture></atl-child-fixture></div> `,
7070
standalone: true,
71-
imports: [ChildFixture],
71+
imports: [ChildFixtureComponent],
7272
})
73-
class ParentFixture { }
73+
class ParentFixtureComponent {}
7474

7575
it('renders the standalone component with child', async () => {
76-
await render(ParentFixture);
77-
expect(screen.getByText('Parent fixture'));
78-
expect(screen.getByText('A child fixture'));
76+
await render(ParentFixtureComponent);
77+
expect(screen.getByText('Parent fixture')).toBeInTheDocument();
78+
expect(screen.getByText('A child fixture')).toBeInTheDocument();
7979
});
8080

81-
it('renders the standalone component with child', async () => {
82-
await render(ParentFixture, { ɵcomponentImports: [MockChildFixture] });
83-
expect(screen.getByText('Parent fixture'));
84-
expect(screen.getByText('A mock child fixture'));
81+
it('renders the standalone component with a mocked child', async () => {
82+
await render(ParentFixtureComponent, { componentImports: [MockChildFixtureComponent] });
83+
expect(screen.getByText('Parent fixture')).toBeInTheDocument();
84+
expect(screen.getByText('A mock child fixture')).toBeInTheDocument();
8585
});
8686

8787
it('rejects render of template with componentImports set', () => {
88-
const result = render(`<div><parent-fixture></parent-fixture></div>`, {
89-
imports: [ParentFixture],
90-
ɵcomponentImports: [MockChildFixture],
88+
const view = render(`<div><atl-parent-fixture></atl-parent-fixture></div>`, {
89+
imports: [ParentFixtureComponent],
90+
componentImports: [MockChildFixtureComponent],
9191
});
92-
return expect(result).rejects.toMatchObject({ message: /Error while rendering/ });
92+
return expect(view).rejects.toMatchObject({ message: /Error while rendering/ });
9393
});
9494
});
9595

@@ -117,7 +117,7 @@ describe('animationModule', () => {
117117
@NgModule({
118118
declarations: [FixtureComponent],
119119
})
120-
class FixtureModule { }
120+
class FixtureModule {}
121121
describe('excludeComponentDeclaration', () => {
122122
it('does not throw if component is declared in an imported module', async () => {
123123
await render(FixtureComponent, {

0 commit comments

Comments
 (0)