We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
test
No response
When testing a component that uses @defer (on timer(2s)), switching the tests to use AoT makes the test fails.
@defer (on timer(2s))
Generate a new app with latest CLI and add a component:
npx @angular/cli@20.0.0-next.9 new defer-aot-repro --defaults --no-routing cd defer-aot-repro ng g c user
Use app-user in app.html:
@defer (on timer(2s)) { <app-user /> }
Change the test to:
import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { App } from './app'; describe('App', () => { beforeEach(async () => { await TestBed.configureTestingModule({ imports: [App], }).compileComponents(); }); it('should render user', fakeAsync(() => { const fixture = TestBed.createComponent(App); fixture.detectChanges(); tick(2000); const compiled = fixture.nativeElement as HTMLElement; expect(compiled.querySelector('p')?.textContent).toContain('user works'); })); });
Run:
ng test --no-watch --code-coverage
Tests are OK 👍
Edit angular.json to add "aot": true in the test section and run:
The test is failing:
Chrome Headless 135.0.0.0 (Mac OS 10.15.7) App should render user FAILED Expected undefined to contain 'user works'.
Angular CLI: 20.0.0-next.9 Node: 22.14.0 Package Manager: npm 10.9.0 OS: darwin arm64 Angular: 20.0.0-next.9 ... build, cli, common, compiler, compiler-cli, core, forms ... platform-browser, router Package Version ------------------------------------------------------ @angular-devkit/architect 0.2000.0-next.9 @angular-devkit/core 20.0.0-next.9 @angular-devkit/schematics 20.0.0-next.9 @schematics/angular 20.0.0-next.9 rxjs 7.8.2 typescript 5.8.3 zone.js 0.15.0
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When testing a component that uses
@defer (on timer(2s))
, switching the tests to use AoT makes the test fails.Minimal Reproduction
Generate a new app with latest CLI and add a component:
Use app-user in app.html:
Change the test to:
Run:
Tests are OK 👍
Edit angular.json to add "aot": true in the test section and run:
The test is failing:
Exception or Error
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: