-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Closed
Copy link
Labels
needs triageThis issue needs to be triaged by the teamThis issue needs to be triaged by the team
Description
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.
- Move the call to
TestbedHarnessEnvironment.loader
to theit
function (demo). - Use
waitForAsync
in thebeforeEach
instead of an async function (demo). - Change the target to ES2016 (demo).
Steps to reproduce:
- 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 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 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/[email protected]/dist/proxy.js:39:23)
at Function.TaskStateZoneInterceptor.setup (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/@angular/[email protected]/bundles/cdk-testing-testbed.umd.js:354:42)
at new TestbedHarnessEnvironment (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/@angular/[email protected]/bundles/cdk-testing-testbed.umd.js:1167:57)
at Function.TestbedHarnessEnvironment.loader (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/@angular/[email protected]/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/[email protected]/dist/zone.js:395:30)
at ProxyZoneSpec.onInvoke (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/[email protected]/dist/proxy.js:125:43)
at ZoneDelegate.invoke (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/[email protected]/dist/zone.js:394:56)
at Zone.run (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/[email protected]/dist/zone.js:155:47)
at runInTestZone (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/[email protected]/dist/jasmine-patch.js:203:38)
at UserContext.eval (https://harness-issue-hsdvet.stackblitz.io/turbo_modules/[email protected]/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
rajsite
Metadata
Metadata
Assignees
Labels
needs triageThis issue needs to be triaged by the teamThis issue needs to be triaged by the team