Closed
Description
Summary
When render(ComponentType)
includes componentOutputs
in its option, TypeScript inference seems broken.
Repro
BTW, I'm preparing a bugfix for this. This is a spec to reproduce the bug.
describe('componentOutputs', () => {
it('invokes given callback when an output is emitted', async () => {
@Component({ template: `` })
class TestFixtureComponent {
@Output() event = new EventEmitter<void>();
emitEvent() {
this.event.emit();
}
}
const spy = jest.fn();
const { fixture } = await render(TestFixtureComponent, {
componentOutputs: { event: spy },
});
fixture.componentInstance.emitEvent();
expect(spy).toHaveBeenCalled();
});
});
projects/testing-library/tests/render.spec.ts:170:31 - error TS2769: No overload matches this call.
Overload 1 of 2, '(component: Type<TestFixtureComponent>, renderOptions?: RenderComponentOptions<TestFixtureComponent, typeof import("/Users/lacolaco/works/angular-testing-library/node_modules/@testing-library/dom/types/queries")> | undefined): Promise<...>', gave the following error.
Type 'Mock<any, any>' is missing the following properties from type 'EventEmitter<void>': emit, subscribe, closed, currentObservers, and 16 more.
Overload 2 of 2, '(template: string, renderOptions?: RenderTemplateOptions<WrapperComponent, {}, typeof import("/Users/lacolaco/works/angular-testing-library/node_modules/@testing-library/dom/types/queries")> | undefined): Promise<...>', gave the following error.
Argument of type 'typeof TestFixtureComponent' is not assignable to parameter of type 'string'.
170 const { fixture } = await render(TestFixtureComponent, {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171 componentOutputs: { event: spy },
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172 });
~~~~~~
Metadata
Metadata
Assignees
Labels
No labels