-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
FW-887: four independent fixes for TestBedRender3 #28033
Conversation
Reviewers: please note the last two commits are the substance of this PR. The first commit is from #27860 which I expect to merge before this one, so I've based mine on it to avoid later conflicts. |
You can preview 0573fff at https://pr28033-0573fff.ngbuilds.io/. |
0573fff
to
e1ba988
Compare
@AndrewKushnir thanks, done. |
You can preview e1ba988 at https://pr28033-e1ba988.ngbuilds.io/. |
e1ba988
to
4c48219
Compare
You can preview 4c48219 at https://pr28033-4c48219.ngbuilds.io/. |
4c48219
to
a25022e
Compare
You can preview a25022e at https://pr28033-a25022e.ngbuilds.io/. |
a25022e
to
54d3da9
Compare
You can preview 54d3da9 at https://pr28033-54d3da9.ngbuilds.io/. |
54d3da9
to
3bb4e2f
Compare
You can preview 3bb4e2f at https://pr28033-3bb4e2f.ngbuilds.io/. |
An @NgModule with an 'id' property has its type registered in a global map of modules by id. This happens during compilation of the module. In Ivy, modules are first compiled when the @NgModule decorator executes. In tests, they might be passed again through the TestBed's compiler, resulting in a second compilation and registration. Before this fix, this second registration would cause an error, as the id was previously registered. This commit makes the registration idempotent, so if the same module type is being registered for the same id then no error is thrown. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed.
An @NgModule with invalid provider declarations produces errors under normal circumstances. However, within the TestBed two small issues with provider overrides interfered with the correct production of these errors: 1. a 'null' provider object caused a premature crash when the TestBed attempted to check for a 'provide' property on it with hasOwnProperty(). 2. the array of providers would have an empty override array appended to it for each input provider, which would pollute the error messages produced down the line. This commit fixes both of these issues, by 1) checking for null and 2) filtering out the empty override arrays. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed.
Previously when testing code injected the Compiler, it received the top-level Compiler implementation defined in linker/compiler.ts (and governed by the __PRE_R3__ switch). Code running under the TestBed, however, should always use a TestBed-aware Compiler implementation. This commit adds such an implementation to the TestBedRender3, which passes compiled modules through the _compileNgModule() function. With this change, 3 formerly disabled router integration tests now pass. FW-855 #resolve
When an @NgModule decorator executes, the module is added to a queue in render3/jit/module.ts. Reading an ngComponentDef property causes this queue to be flushed, ensuring that the component gets the correct module scope applied. In before_each.ts, a global beforeEach is added to all Angular tests which calls TestBed.resetTestingModule() prior to running each test. This in turn clears the module compilation queue (which is correct behavior, as modules declared within the test should not leak outside of it via the queue). So far this is okay. But before the first test runs, the module compilation queue is full of modules declared in global scope. No definitions have been read, so no flushes of the queue have been triggered. The global beforeEach triggers a reset of the queue, aborting all of the in-progress global compilation, breaking those classes when they're later used in tests. This commit adds logic to TestBedRender3 to respect the state of the module queue before the TestBed is first initialized or reset. The queue is flushed prior to such an operation to ensure global compilation is allowed to finish properly. With this fix, a platform-server test now passes (previously the <my-child> element was not detected as a component, because the encompassing module never finished compilation. FW-887 #resolve
3bb4e2f
to
975257a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @alxhub!
An @NgModule with invalid provider declarations produces errors under normal circumstances. However, within the TestBed two small issues with provider overrides interfered with the correct production of these errors: 1. a 'null' provider object caused a premature crash when the TestBed attempted to check for a 'provide' property on it with hasOwnProperty(). 2. the array of providers would have an empty override array appended to it for each input provider, which would pollute the error messages produced down the line. This commit fixes both of these issues, by 1) checking for null and 2) filtering out the empty override arrays. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close #28033
Previously when testing code injected the Compiler, it received the top-level Compiler implementation defined in linker/compiler.ts (and governed by the __PRE_R3__ switch). Code running under the TestBed, however, should always use a TestBed-aware Compiler implementation. This commit adds such an implementation to the TestBedRender3, which passes compiled modules through the _compileNgModule() function. With this change, 3 formerly disabled router integration tests now pass. FW-855 #resolve PR Close #28033
…les (#28033) When an @NgModule decorator executes, the module is added to a queue in render3/jit/module.ts. Reading an ngComponentDef property causes this queue to be flushed, ensuring that the component gets the correct module scope applied. In before_each.ts, a global beforeEach is added to all Angular tests which calls TestBed.resetTestingModule() prior to running each test. This in turn clears the module compilation queue (which is correct behavior, as modules declared within the test should not leak outside of it via the queue). So far this is okay. But before the first test runs, the module compilation queue is full of modules declared in global scope. No definitions have been read, so no flushes of the queue have been triggered. The global beforeEach triggers a reset of the queue, aborting all of the in-progress global compilation, breaking those classes when they're later used in tests. This commit adds logic to TestBedRender3 to respect the state of the module queue before the TestBed is first initialized or reset. The queue is flushed prior to such an operation to ensure global compilation is allowed to finish properly. With this fix, a platform-server test now passes (previously the <my-child> element was not detected as a component, because the encompassing module never finished compilation. FW-887 #resolve PR Close #28033
An @NgModule with an 'id' property has its type registered in a global map of modules by id. This happens during compilation of the module. In Ivy, modules are first compiled when the @NgModule decorator executes. In tests, they might be passed again through the TestBed's compiler, resulting in a second compilation and registration. Before this fix, this second registration would cause an error, as the id was previously registered. This commit makes the registration idempotent, so if the same module type is being registered for the same id then no error is thrown. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
…28033) An @NgModule with invalid provider declarations produces errors under normal circumstances. However, within the TestBed two small issues with provider overrides interfered with the correct production of these errors: 1. a 'null' provider object caused a premature crash when the TestBed attempted to check for a 'provide' property on it with hasOwnProperty(). 2. the array of providers would have an empty override array appended to it for each input provider, which would pollute the error messages produced down the line. This commit fixes both of these issues, by 1) checking for null and 2) filtering out the empty override arrays. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
) Previously when testing code injected the Compiler, it received the top-level Compiler implementation defined in linker/compiler.ts (and governed by the __PRE_R3__ switch). Code running under the TestBed, however, should always use a TestBed-aware Compiler implementation. This commit adds such an implementation to the TestBedRender3, which passes compiled modules through the _compileNgModule() function. With this change, 3 formerly disabled router integration tests now pass. FW-855 #resolve PR Close angular#28033
…les (angular#28033) When an @NgModule decorator executes, the module is added to a queue in render3/jit/module.ts. Reading an ngComponentDef property causes this queue to be flushed, ensuring that the component gets the correct module scope applied. In before_each.ts, a global beforeEach is added to all Angular tests which calls TestBed.resetTestingModule() prior to running each test. This in turn clears the module compilation queue (which is correct behavior, as modules declared within the test should not leak outside of it via the queue). So far this is okay. But before the first test runs, the module compilation queue is full of modules declared in global scope. No definitions have been read, so no flushes of the queue have been triggered. The global beforeEach triggers a reset of the queue, aborting all of the in-progress global compilation, breaking those classes when they're later used in tests. This commit adds logic to TestBedRender3 to respect the state of the module queue before the TestBed is first initialized or reset. The queue is flushed prior to such an operation to ensure global compilation is allowed to finish properly. With this fix, a platform-server test now passes (previously the <my-child> element was not detected as a component, because the encompassing module never finished compilation. FW-887 #resolve PR Close angular#28033
An @NgModule with an 'id' property has its type registered in a global map of modules by id. This happens during compilation of the module. In Ivy, modules are first compiled when the @NgModule decorator executes. In tests, they might be passed again through the TestBed's compiler, resulting in a second compilation and registration. Before this fix, this second registration would cause an error, as the id was previously registered. This commit makes the registration idempotent, so if the same module type is being registered for the same id then no error is thrown. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
…28033) An @NgModule with invalid provider declarations produces errors under normal circumstances. However, within the TestBed two small issues with provider overrides interfered with the correct production of these errors: 1. a 'null' provider object caused a premature crash when the TestBed attempted to check for a 'provide' property on it with hasOwnProperty(). 2. the array of providers would have an empty override array appended to it for each input provider, which would pollute the error messages produced down the line. This commit fixes both of these issues, by 1) checking for null and 2) filtering out the empty override arrays. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
) Previously when testing code injected the Compiler, it received the top-level Compiler implementation defined in linker/compiler.ts (and governed by the __PRE_R3__ switch). Code running under the TestBed, however, should always use a TestBed-aware Compiler implementation. This commit adds such an implementation to the TestBedRender3, which passes compiled modules through the _compileNgModule() function. With this change, 3 formerly disabled router integration tests now pass. FW-855 #resolve PR Close angular#28033
…les (angular#28033) When an @NgModule decorator executes, the module is added to a queue in render3/jit/module.ts. Reading an ngComponentDef property causes this queue to be flushed, ensuring that the component gets the correct module scope applied. In before_each.ts, a global beforeEach is added to all Angular tests which calls TestBed.resetTestingModule() prior to running each test. This in turn clears the module compilation queue (which is correct behavior, as modules declared within the test should not leak outside of it via the queue). So far this is okay. But before the first test runs, the module compilation queue is full of modules declared in global scope. No definitions have been read, so no flushes of the queue have been triggered. The global beforeEach triggers a reset of the queue, aborting all of the in-progress global compilation, breaking those classes when they're later used in tests. This commit adds logic to TestBedRender3 to respect the state of the module queue before the TestBed is first initialized or reset. The queue is flushed prior to such an operation to ensure global compilation is allowed to finish properly. With this fix, a platform-server test now passes (previously the <my-child> element was not detected as a component, because the encompassing module never finished compilation. FW-887 #resolve PR Close angular#28033
An @NgModule with an 'id' property has its type registered in a global map of modules by id. This happens during compilation of the module. In Ivy, modules are first compiled when the @NgModule decorator executes. In tests, they might be passed again through the TestBed's compiler, resulting in a second compilation and registration. Before this fix, this second registration would cause an error, as the id was previously registered. This commit makes the registration idempotent, so if the same module type is being registered for the same id then no error is thrown. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
…28033) An @NgModule with invalid provider declarations produces errors under normal circumstances. However, within the TestBed two small issues with provider overrides interfered with the correct production of these errors: 1. a 'null' provider object caused a premature crash when the TestBed attempted to check for a 'provide' property on it with hasOwnProperty(). 2. the array of providers would have an empty override array appended to it for each input provider, which would pollute the error messages produced down the line. This commit fixes both of these issues, by 1) checking for null and 2) filtering out the empty override arrays. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
) Previously when testing code injected the Compiler, it received the top-level Compiler implementation defined in linker/compiler.ts (and governed by the __PRE_R3__ switch). Code running under the TestBed, however, should always use a TestBed-aware Compiler implementation. This commit adds such an implementation to the TestBedRender3, which passes compiled modules through the _compileNgModule() function. With this change, 3 formerly disabled router integration tests now pass. FW-855 #resolve PR Close angular#28033
…les (angular#28033) When an @NgModule decorator executes, the module is added to a queue in render3/jit/module.ts. Reading an ngComponentDef property causes this queue to be flushed, ensuring that the component gets the correct module scope applied. In before_each.ts, a global beforeEach is added to all Angular tests which calls TestBed.resetTestingModule() prior to running each test. This in turn clears the module compilation queue (which is correct behavior, as modules declared within the test should not leak outside of it via the queue). So far this is okay. But before the first test runs, the module compilation queue is full of modules declared in global scope. No definitions have been read, so no flushes of the queue have been triggered. The global beforeEach triggers a reset of the queue, aborting all of the in-progress global compilation, breaking those classes when they're later used in tests. This commit adds logic to TestBedRender3 to respect the state of the module queue before the TestBed is first initialized or reset. The queue is flushed prior to such an operation to ensure global compilation is allowed to finish properly. With this fix, a platform-server test now passes (previously the <my-child> element was not detected as a component, because the encompassing module never finished compilation. FW-887 #resolve PR Close angular#28033
An @NgModule with an 'id' property has its type registered in a global map of modules by id. This happens during compilation of the module. In Ivy, modules are first compiled when the @NgModule decorator executes. In tests, they might be passed again through the TestBed's compiler, resulting in a second compilation and registration. Before this fix, this second registration would cause an error, as the id was previously registered. This commit makes the registration idempotent, so if the same module type is being registered for the same id then no error is thrown. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
…28033) An @NgModule with invalid provider declarations produces errors under normal circumstances. However, within the TestBed two small issues with provider overrides interfered with the correct production of these errors: 1. a 'null' provider object caused a premature crash when the TestBed attempted to check for a 'provide' property on it with hasOwnProperty(). 2. the array of providers would have an empty override array appended to it for each input provider, which would pollute the error messages produced down the line. This commit fixes both of these issues, by 1) checking for null and 2) filtering out the empty override arrays. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
) Previously when testing code injected the Compiler, it received the top-level Compiler implementation defined in linker/compiler.ts (and governed by the __PRE_R3__ switch). Code running under the TestBed, however, should always use a TestBed-aware Compiler implementation. This commit adds such an implementation to the TestBedRender3, which passes compiled modules through the _compileNgModule() function. With this change, 3 formerly disabled router integration tests now pass. FW-855 #resolve PR Close angular#28033
…les (angular#28033) When an @NgModule decorator executes, the module is added to a queue in render3/jit/module.ts. Reading an ngComponentDef property causes this queue to be flushed, ensuring that the component gets the correct module scope applied. In before_each.ts, a global beforeEach is added to all Angular tests which calls TestBed.resetTestingModule() prior to running each test. This in turn clears the module compilation queue (which is correct behavior, as modules declared within the test should not leak outside of it via the queue). So far this is okay. But before the first test runs, the module compilation queue is full of modules declared in global scope. No definitions have been read, so no flushes of the queue have been triggered. The global beforeEach triggers a reset of the queue, aborting all of the in-progress global compilation, breaking those classes when they're later used in tests. This commit adds logic to TestBedRender3 to respect the state of the module queue before the TestBed is first initialized or reset. The queue is flushed prior to such an operation to ensure global compilation is allowed to finish properly. With this fix, a platform-server test now passes (previously the <my-child> element was not detected as a component, because the encompassing module never finished compilation. FW-887 #resolve PR Close angular#28033
An @NgModule with an 'id' property has its type registered in a global map of modules by id. This happens during compilation of the module. In Ivy, modules are first compiled when the @NgModule decorator executes. In tests, they might be passed again through the TestBed's compiler, resulting in a second compilation and registration. Before this fix, this second registration would cause an error, as the id was previously registered. This commit makes the registration idempotent, so if the same module type is being registered for the same id then no error is thrown. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
…28033) An @NgModule with invalid provider declarations produces errors under normal circumstances. However, within the TestBed two small issues with provider overrides interfered with the correct production of these errors: 1. a 'null' provider object caused a premature crash when the TestBed attempted to check for a 'provide' property on it with hasOwnProperty(). 2. the array of providers would have an empty override array appended to it for each input provider, which would pollute the error messages produced down the line. This commit fixes both of these issues, by 1) checking for null and 2) filtering out the empty override arrays. Testing strategy: future commits change the way the TestBed compiles modules, causing tests to become sensitive to this bug if not fixed. PR Close angular#28033
) Previously when testing code injected the Compiler, it received the top-level Compiler implementation defined in linker/compiler.ts (and governed by the __PRE_R3__ switch). Code running under the TestBed, however, should always use a TestBed-aware Compiler implementation. This commit adds such an implementation to the TestBedRender3, which passes compiled modules through the _compileNgModule() function. With this change, 3 formerly disabled router integration tests now pass. FW-855 #resolve PR Close angular#28033
…les (angular#28033) When an @NgModule decorator executes, the module is added to a queue in render3/jit/module.ts. Reading an ngComponentDef property causes this queue to be flushed, ensuring that the component gets the correct module scope applied. In before_each.ts, a global beforeEach is added to all Angular tests which calls TestBed.resetTestingModule() prior to running each test. This in turn clears the module compilation queue (which is correct behavior, as modules declared within the test should not leak outside of it via the queue). So far this is okay. But before the first test runs, the module compilation queue is full of modules declared in global scope. No definitions have been read, so no flushes of the queue have been triggered. The global beforeEach triggers a reset of the queue, aborting all of the in-progress global compilation, breaking those classes when they're later used in tests. This commit adds logic to TestBedRender3 to respect the state of the module queue before the TestBed is first initialized or reset. The queue is flushed prior to such an operation to ensure global compilation is allowed to finish properly. With this fix, a platform-server test now passes (previously the <my-child> element was not detected as a component, because the encompassing module never finished compilation. FW-887 #resolve PR Close angular#28033
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.