Skip to content

Commit a04c76c

Browse files
committed
fix(@schematics/angular): align Karma project generation with unified unit-test builder
Updates the application and ng-new schematics to correctly configure Karma-based projects. - The test target in the generated angular.json now uses the `@angular/build:unit-test` builder. - The builder options are simplified to only include runner: 'karma', as other settings are now handled by the unified builder. - Corresponding schematic tests have been updated to reflect these changes.
1 parent cf47d15 commit a04c76c

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

packages/schematics/angular/application/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,9 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul
396396
options: {},
397397
}
398398
: {
399-
builder: Builders.BuildKarma,
399+
builder: Builders.BuildUnitTest,
400400
options: {
401-
polyfills: options.zoneless ? undefined : ['zone.js', 'zone.js/testing'],
402-
tsConfig: `${projectRoot}tsconfig.spec.json`,
403-
inlineStyleLanguage,
404-
assets: [{ 'glob': '**/*', 'input': `${projectRoot}public` }],
405-
styles: [`${sourceRoot}/styles.${options.style}`],
401+
runner: 'karma',
406402
},
407403
},
408404
},

packages/schematics/angular/application/index_spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,11 @@ describe('Application Schematic', () => {
448448
const config = JSON.parse(tree.readContent('/angular.json'));
449449
const prj = config.projects.foo;
450450
const testOpt = prj.architect.test;
451-
expect(testOpt.builder).toEqual('@angular/build:karma');
452-
expect(testOpt.options.tsConfig).toEqual('tsconfig.spec.json');
453-
expect(testOpt.options.assets).toEqual([{ glob: '**/*', input: 'public' }]);
454-
expect(testOpt.options.styles).toEqual(['src/styles.css']);
451+
expect(testOpt.builder).toEqual('@angular/build:unit-test');
452+
expect(testOpt.options.runner).toEqual('karma');
453+
expect(testOpt.options.tsConfig).toBeUndefined();
454+
expect(testOpt.options.assets).toBeUndefined();
455+
expect(testOpt.options.styles).toBeUndefined();
455456
});
456457

457458
it('should set the relative tsconfig paths', async () => {

packages/schematics/angular/ng-new/index_spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ describe('Ng New Schematic', () => {
169169
},
170170
},
171171
} = JSON.parse(tree.readContent('/bar/angular.json'));
172-
expect(test.builder).toBe('@angular/build:karma');
172+
expect(test.builder).toBe('@angular/build:unit-test');
173+
expect(test.options).toEqual({ runner: 'karma' });
173174

174175
const { devDependencies } = JSON.parse(tree.readContent('/bar/package.json'));
175176
expect(devDependencies['karma']).toBeDefined();

0 commit comments

Comments
 (0)