Skip to content

Commit aad74d3

Browse files
authored
fix(cdk/testing): use directive fixture onDestroy (#33793)
Uses the `DirectiveFixture.onDestroy` instead of injecting the `DestroyRef` which is problematic internally.
1 parent e81c398 commit aad74d3

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/cdk/testing/testbed/testbed-harness-environment.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ import {
1515
stopHandlingAutoChangeDetectionStatus,
1616
TestElement,
1717
} from '../../testing';
18-
import {ComponentFixture, DirectiveFixture, flush, TestBed} from '@angular/core/testing';
18+
import {ComponentFixture, DirectiveFixture, flush} from '@angular/core/testing';
1919
import {Observable} from 'rxjs';
2020
import {takeWhile} from 'rxjs/operators';
2121
import {TaskState, TaskStateZoneInterceptor} from './task-state-zone-interceptor';
2222
import {UnitTestElement} from './unit-test-element';
23-
import {DestroyRef} from '@angular/core';
2423

2524
/** Options to configure the environment. */
2625
export interface TestbedHarnessEnvironmentOptions {
@@ -124,8 +123,7 @@ export class TestbedHarnessEnvironment extends HarnessEnvironment<Element> {
124123
if (_fixture instanceof ComponentFixture) {
125124
_fixture.componentRef.onDestroy(onDestroy);
126125
} else {
127-
// TODO(crisbeto): use host ref in directive fixture once it's available.
128-
TestBed.inject(DestroyRef).onDestroy(onDestroy);
126+
_fixture.onDestroy(onDestroy);
129127
}
130128
}
131129

0 commit comments

Comments
 (0)