diff --git a/packages/core/test/component_fixture_spec.ts b/packages/core/test/component_fixture_spec.ts index cc20cca2139c5..f7f206c78dba2 100644 --- a/packages/core/test/component_fixture_spec.ts +++ b/packages/core/test/component_fixture_spec.ts @@ -581,4 +581,20 @@ describe('ComponentFixture with zoneless', () => { // still throws if checkNoChanges is not disabled expect(() => fixture.detectChanges()).toThrowError(/ExpressionChanged/); }); + + it('runs change detection when autoDetect is false', () => { + @Component({ + template: '{{thing()}}', + standalone: true, + }) + class App { + thing = signal(1); + } + + const fixture = TestBed.createComponent(App); + fixture.autoDetectChanges(false); + fixture.componentInstance.thing.set(2); + fixture.detectChanges(); + expect(fixture.nativeElement.innerText).toBe('2'); + }); }); diff --git a/packages/core/testing/src/component_fixture.ts b/packages/core/testing/src/component_fixture.ts index c9122f6ca359a..9e9767ef3dc17 100644 --- a/packages/core/testing/src/component_fixture.ts +++ b/packages/core/testing/src/component_fixture.ts @@ -140,7 +140,14 @@ export class ComponentFixture { } if (this.zonelessEnabled) { - this._appRef.tick(); + try { + this._testAppRef.externalTestViews.add(this.componentRef.hostView); + this._appRef.tick(); + } finally { + if (!this.autoDetect) { + this._testAppRef.externalTestViews.delete(this.componentRef.hostView); + } + } } else { // Run the change detection inside the NgZone so that any async tasks as part of the change // detection are captured by the zone and can be waited for in isStable.