You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a unit test describe block that includes the harness loader.
Assign the harness loader in the beforeEach function.
Get a harness with await loader.getHander in an async it function.
Expected Behavior
I'd expect the test to pass, because it is setup as described in component harness documentation and ES2018 is the generated default target.
Actual Behavior
TestbedHarnessEnvironment.loader returns undefined in the beforeEach, and the test fails with the following.
Error: Expected to be running in'ProxyZone', but it was not found.
at Function.ProxyZoneSpec.assertPresent (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/zone.js@0.11.3/dist/proxy.js:39:23)
at Function.TaskStateZoneInterceptor.setup (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/@angular/cdk@11.0.4/bundles/cdk-testing-testbed.umd.js:354:42)
at new TestbedHarnessEnvironment (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/@angular/cdk@11.0.4/bundles/cdk-testing-testbed.umd.js:1167:57)
at Function.TestbedHarnessEnvironment.loader (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/@angular/cdk@11.0.4/bundles/cdk-testing-testbed.umd.js:1177:20)
at UserContext.eval (https://harness-issue-hsdvet.stackblitz.io/~/src/app/button-harness-example.spec.ts:21:54)
TypeError: Cannot read property 'getHarness' of undefined
at UserContext.eval (https://harness-issue-hsdvet.stackblitz.io/~/src/app/button-harness-example.spec.ts:24:37)
at ZoneDelegate.invoke (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/zone.js@0.11.3/dist/zone.js:395:30)
at ProxyZoneSpec.onInvoke (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/zone.js@0.11.3/dist/proxy.js:125:43)
at ZoneDelegate.invoke (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/zone.js@0.11.3/dist/zone.js:394:56)
at Zone.run (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/zone.js@0.11.3/dist/zone.js:155:47)
at runInTestZone (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/zone.js@0.11.3/dist/jasmine-patch.js:203:38)
at UserContext.eval (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/zone.js@0.11.3/dist/jasmine-patch.js:218:24)
at <Jasmine>
Environment
Angular: 11.0.9
CDK/Material: 11.0.4
Browser(s): Chrome 87.0.4280.141
Operating System (e.g. Windows, macOS, Ubuntu): macOS 11.1
The text was updated successfully, but these errors were encountered:
Angular does not actually work with any ES2017 or later output. This is because zone.js cannot patch the native async and await syntax. You can follow the canonical issue for this here: angular/angular#31730. Resolving this is on Angular's roadmap.
@jelbourn This might not be the place, but I'd like to selfishly leave a quick piece of feedback. Supporting async/await in testing is awesome! However, I would have expected support for ES next with an option for async/await from your roadmap rather than a blanket drop in support for the whole standard. I don't even use async/await in my application code, because it doesn't support the component lifecycle. That is critical given the types of applications I build, and I find the advantages of CD and RxJS outweigh async/await. I hope the framework continues to progress beyond the standards in those respects after Zone becomes optional. I've been targeting ES2018 for some time, lol.
Reproduction
The unit tests fail when the harness loader is created in an async
beforeEach
and the TS target is ES2018.StackBlitz Demo
There are three solutions to this problem.
TestbedHarnessEnvironment.loader
to theit
function (demo).waitForAsync
in thebeforeEach
instead of an async function (demo).Steps to reproduce:
describe
block that includes the harness loader.beforeEach
function.await loader.getHander
in an asyncit
function.Expected Behavior
I'd expect the test to pass, because it is setup as described in component harness documentation and ES2018 is the generated default target.
Actual Behavior
TestbedHarnessEnvironment.loader
returns undefined in thebeforeEach
, and the test fails with the following.Environment
The text was updated successfully, but these errors were encountered: