Skip to content
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

fix(ivy): TestBed not unwrapping imports array function when overriding provider #34629

Closed

Conversation

@crisbeto
Copy link
Member

crisbeto commented Jan 3, 2020

Fixes an error that is thrown when a provider is overridden in TestBed, if the module definition of one of the imported modules uses a function for the imports that is set via setNgModuleScope. The problem was that we have a for...of loop that assumes that the imports are an array, but they can also be a function. This was handled correctly in other places, but the one here was missed.

Note that the above-mentioned error is only thrown at runtime when the code is transpiled to es6. In es5 TS generates a call to a helper that handles the error silently so the attached unit test only fails in es6.

Fixes #34623.

@googlebot googlebot added the cla: yes label Jan 3, 2020
@ngbot ngbot bot modified the milestone: needsTriage Jan 3, 2020
@crisbeto crisbeto marked this pull request as ready for review Jan 3, 2020
@crisbeto crisbeto requested a review from angular/fw-core as a code owner Jan 3, 2020
Copy link
Contributor

AndrewKushnir left a comment

LGTM (with one minor comment), thanks for the fix @crisbeto 👍

packages/core/test/test_bed_spec.ts Outdated Show resolved Hide resolved
@AndrewKushnir

This comment has been minimized.

Copy link
Contributor

AndrewKushnir commented Jan 3, 2020

…ng provider

Fixes an error that is thrown when a provider is overridden in `TestBed`, if the module definition of one of the imported modules uses a function for the `imports` that is set via `setNgModuleScope`. The problem was that we have a `for...of` loop that assumes that the imports are an array, but they can also be a function. This was handled correctly in other places, but this one was missed.

Note that the above-mentioned error is only thrown at runtime when the code is transpiled to es6. In es5 TS generates a call to a helper that handles the error silently so the attached unit test only fails in es6.

Fixes #34623.
@crisbeto crisbeto force-pushed the crisbeto:34623/ivy-testbed-es6-error branch from 9e79bbe to 33fcef2 Jan 3, 2020
alxhub added a commit that referenced this pull request Jan 6, 2020
…ng provider (#34629)

Fixes an error that is thrown when a provider is overridden in `TestBed`, if the module definition of one of the imported modules uses a function for the `imports` that is set via `setNgModuleScope`. The problem was that we have a `for...of` loop that assumes that the imports are an array, but they can also be a function. This was handled correctly in other places, but this one was missed.

Note that the above-mentioned error is only thrown at runtime when the code is transpiled to es6. In es5 TS generates a call to a helper that handles the error silently so the attached unit test only fails in es6.

Fixes #34623.

PR Close #34629
@alxhub alxhub closed this in 5b864ed Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.