-
Notifications
You must be signed in to change notification settings - Fork 91
Request: Add template
to RenderComponentOptions
#203
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
Comments
I agree! The only "problem" is that the type won't be I think the name of |
@timdeschryver I can understand what you want to say, but I'm not expecting it (so far). const onSomeEvent = jest.fn();
const { rerender } = await render(FooComponent, {
template: `<app-foo [someFlag]="someFlag" (someEvent)="onSomeEvent($event)"></app-foo>`,
componentProperties: {
someFlag: true,
onSomeEvent,
}
});
rerender({ someFlag: false }); I don't think this design is a mistake, but maybe not intuitive. My rough idea is adding
const onSomeEvent = jest.fn();
await render(`<app-foo [someFlag]="someFlag" (someEvent)="onSomeEvent($event)"></app-foo>`, {
declarations: [FooComponent],
hostProperties: {
someFlag: true,
onSomeEvent,
}
}); Honestly, I prefer separating two APIs like How do you think? |
I prefer to just keep it as I really like the alternative version to render a template! |
I'd like to create a PR as my first contribution for testing-library! 👍 I'll work on it in a few days. |
Awesome, thanks @lacolaco ! |
🎉 This issue has been resolved in version 10.6.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
https://github.com/testing-library/angular-testing-library/blob/master/projects/testing-library/src/lib/models.ts#L266
TypeScript cannot determine which
Type
is a component or directive. Becausetemplate
is from onlyRenderDirectiveOptions
, TypeScript language service cannot suggest it for autocompletion.In my opinion,
render(Comp, { template })
is a common use-case, and it actually works well. I'm usingrender(Comp, { template }
for my specs to use it as a living usage documentation at same time.The text was updated successfully, but these errors were encountered: