Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: fix config for testing with zoneless Angular #535

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

Merged
timdeschryver merged 1 commit into testing-library:beta from mikeshtro:fix-zoneless
Jul 14, 2025

Conversation

Copy link

@mikeshtro mikeshtro commented Jul 11, 2025

This PR fixes zoneless flag in the configure function. I tried to use the configure function with zoneless flag

function setup() {
 configure({ zoneless: true });
 return render(MyComponent);
}

but I got error Unexpected value 'undefined' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation.

This is because provideZonelessChangeDetection is incorrectly used inside imports instead of providers.

Copy link
Member

timdeschryver commented Jul 12, 2025
edited
Loading

Thanks for raising this PR @mikeshtro
I also got a question. Do you think it's useful to also add this config to the render method, because currently it's set at the global level using the configure method.
My reasoning is that either you use zoneless or not for the whole application, and thus it isn't needed to set at test-level.

Copy link
Author

My original idea was to add it to the render method, because I consider it to be the main method, how I setup my tests when using testing library.
But as you described we use zoneless or not for the whole application and so I think the configure method is enough, because it covers the main scenario. If we want to configure it at test-level we can always provide it manually

render(MyComponent, {
 providers: [provideZonelessChangeDetection()]
})

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mikeshtro !

@timdeschryver timdeschryver merged commit 06bb84e into testing-library:beta Jul 14, 2025
6 checks passed
Copy link
Member

@all-contributors please add @mikeshtro for code, bug

Copy link
Contributor

@timdeschryver

I've put up a pull request to add @mikeshtro! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@timdeschryver timdeschryver timdeschryver approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /