diff --git a/packages/localize/schematics/ng-add/index.ts b/packages/localize/schematics/ng-add/index.ts index b5fa0fafa4a4..409cf5e94283 100644 --- a/packages/localize/schematics/ng-add/index.ts +++ b/packages/localize/schematics/ng-add/index.ts @@ -36,6 +36,7 @@ function addPolyfillToConfig(projectName: string): Rule { for (const target of project.targets.values()) { switch (target.builder) { case AngularBuilder.Karma: + case AngularBuilder.BuildKarma: case AngularBuilder.Server: case AngularBuilder.Browser: case AngularBuilder.BrowserEsbuild: diff --git a/packages/localize/schematics/ng-add/index_spec.ts b/packages/localize/schematics/ng-add/index_spec.ts index b6f37abbd695..c9a4f9666eaa 100644 --- a/packages/localize/schematics/ng-add/index_spec.ts +++ b/packages/localize/schematics/ng-add/index_spec.ts @@ -77,6 +77,13 @@ describe('ng-add schematic', () => { polyfills: 'zone.js', }, }, + testKarmaBuild: { + builder: '@angular/build:karma', + options: { + tsConfig: './tsconfig.spec.json', + polyfills: 'zone.js', + }, + }, server: { builder: '@angular-devkit/build-angular:server', options: { @@ -173,6 +180,13 @@ describe('ng-add schematic', () => { expect(polyfills).toEqual(['zone.js', '@angular/localize/init']); }); + it(`should add '@angular/localize/init' in 'polyfills' in karma application builder`, async () => { + host = await schematicRunner.runSchematic('ng-add', defaultOptions, host); + const workspace = host.readJson('angular.json') as any; + const polyfills = workspace.projects['demo'].architect.testKarmaBuild.options.polyfills; + expect(polyfills).toEqual(['zone.js', '@angular/localize/init']); + }); + it(`should add '@angular/localize/init' in 'polyfills' in browser builder`, async () => { host = await schematicRunner.runSchematic('ng-add', defaultOptions, host); const workspace = host.readJson('angular.json') as any;