Skip to content

Add API for defer blocks #415

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

Closed
Christian24 opened this issue Nov 6, 2023 · 5 comments · Fixed by #418
Closed

Add API for defer blocks #415

Christian24 opened this issue Nov 6, 2023 · 5 comments · Fixed by #418

Comments

@Christian24
Copy link

Christian24 commented Nov 6, 2023

Hello,

defer blocks are now in developer preview with Angular 17. There seem to be new features in component fixtures. Are there already plans how to support this in testing-library?

The API Angular provides for this seems to be pretty straightforward, so maybe it should just be wrapped?

@timdeschryver
Copy link
Member

Thanks for bringing this up, I wasn't aware of this yet.
This should already be possible because render returns the component fixture.
When this lib is upgraded to v17, we'll include an example.

@Christian24
Copy link
Author

Maybe we could make it a bit easier even:

maybe render could return a new field deferBlocks? Or a function getDeferBlocks()? I don't know if falling back completely to component fixtures is the way to go.

@timdeschryver
Copy link
Member

timdeschryver commented Nov 11, 2023

Yea, ideally we have an API for that but in the meantime using fixture is a way to do this.
Sadly I don't see an easy way to query a defer block, instead of getDeferBlocks() I was thinking to expose a method that does the following:

// renderDeferState or renderDefer or renderDeferBlock or renderBlock 😅
// or rerender/set/...?
const { renderDeferState } = render(AppComponent);

// set the defer state of the first defer block
await renderDeferState(DeferBlockState.Complete)


// set a specific defer block using the index
await renderDeferState(DeferBlockState.Complete, 2)

@timdeschryver
Copy link
Member

@Christian24 what do you think of the API introduced in #418 ?

@Christian24
Copy link
Author

Christian24 commented Nov 14, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants