GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing github.com — karma builder: component imported through a barrel is undefined in TestBed when another spec has an async test (cross-chunk lazy init, karma counterpart of #33728) · Issue #34250 · angular/angular-cli Open Labels Milestone DescriptionWhich @angular/* package(s) are the source of the bug?build Is this a regression?No DescriptionWith the This looks like the karma counterpart of #33728. The mechanism is the same: shared chunks, lazy What happens in the emitted bundle:
Trigger conditions, each toggled on its own in the reproduction below:
Minimal ReproductionEight small files, run with angular.json (test target only) {
"version": 1,
"projects": {
"repro": {
"projectType": "application",
"root": "",
"sourceRoot": "src",
"architect": {
"test": {
"builder": "@angular/build:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"browsers": "ChromeHeadless"
}
}
}
}
}
}tsconfig.json {
"compilerOptions": {
"strict": true, "skipLibCheck": true, "isolatedModules": true,
"experimentalDecorators": true, "importHelpers": true,
"target": "ES2022", "module": "preserve"
}
}
src/app/layout/form-layout.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-form-layout', template: '<ng-content />' }) export class FormLayoutComponent {} src/app/layout/index.ts export * from './form-layout.component'; src/app/a/dialog.component.ts import { Component } from '@angular/core'; import { FormLayoutComponent } from '../layout'; @Component({ selector: 'app-dialog', imports: [FormLayoutComponent], template: '<app-form-layout>dialog</app-form-layout>', }) export class DialogComponent {} src/app/a/dialog.component.spec.ts and src/app/a/dialog-again.spec.ts (identical, two consumers of import { TestBed } from '@angular/core/testing'; import { DialogComponent } from './dialog.component'; describe('DialogComponent', () => { it('creates', () => { TestBed.configureTestingModule({ imports: [DialogComponent] }); expect(TestBed.createComponent(DialogComponent).componentInstance).toBeTruthy(); }); }); src/app/c/page.component.ts (a third importer of the barrel) and its spec import { Component } from '@angular/core'; import { FormLayoutComponent } from '../layout'; @Component({ selector: 'app-page', imports: [FormLayoutComponent], template: '<app-form-layout>page</app-form-layout>', }) export class PageComponent {} import { TestBed } from '@angular/core/testing'; import { PageComponent } from './page.component'; describe('PageComponent', () => { it('creates', () => { TestBed.configureTestingModule({ imports: [PageComponent] }); expect(TestBed.createComponent(PageComponent).componentInstance).toBeTruthy(); }); }); src/app/b/other.spec.ts (the only spec with an import { TestBed } from '@angular/core/testing'; import { FormLayoutComponent } from '../layout/form-layout.component'; describe('Other (has an async test)', () => { it('creates the layout', async () => { TestBed.configureTestingModule({ imports: [FormLayoutComponent] }); await Promise.resolve(); expect(TestBed.createComponent(FormLayoutComponent).componentInstance).toBeTruthy(); }); }); Result: Exception or ErrorYour EnvironmentAnything else relevant?
Activity
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |