File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed
packages/angular_devkit/build_angular/src/builders/jest
tests/legacy-cli/e2e/tests/jest Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ export default createBuilder(
8585 tsConfig : options . tsConfig ,
8686 polyfills : options . polyfills ?? [ 'zone.js' , 'zone.js/testing' ] ,
8787 outputPath : testOut ,
88- aot : false ,
88+ aot : options . aot ,
8989 index : false ,
9090 outputHashing : OutputHashing . None ,
9191 outExtension : 'mjs' , // Force native ESM.
Original file line number Diff line number Diff line change 3232 "uniqueItems" : true
3333 },
3434 "default" : []
35+ },
36+ "aot" : {
37+ "type" : " boolean" ,
38+ "description" : " Run tests using Ahead of Time compilation." ,
39+ "default" : false
3540 }
3641 },
3742 "additionalProperties" : false ,
Original file line number Diff line number Diff line change 1+ import { deleteFile , writeFile } from '../../utils/fs' ;
2+ import { updateJsonFile } from '../../utils/project' ;
3+ import { applyJestBuilder } from '../../utils/jest' ;
4+ import { ng } from '../../utils/process' ;
5+
6+ export default async function ( ) : Promise < void > {
7+ await applyJestBuilder ( ) ;
8+
9+ {
10+ await updateJsonFile ( 'tsconfig.spec.json' , ( json ) => {
11+ return {
12+ ...json ,
13+ include : [ 'src/**/*.spec.ts' ] ,
14+ } ;
15+ } ) ;
16+
17+ await writeFile (
18+ 'src/aot.spec.ts' ,
19+ `
20+ import { Component } from '@angular/core';
21+
22+ describe('Hello', () => {
23+ it('should *not* contain jit instructions', () => {
24+ @Component({
25+ template: 'Hello',
26+ })
27+ class Hello {}
28+
29+ expect((Hello as any).ɵcmp.template.toString()).not.toContain('jit');
30+ });
31+ });
32+ ` . trim ( ) ,
33+ ) ;
34+
35+ const { stderr } = await ng ( 'test' , '--aot' ) ;
36+
37+ if ( ! stderr . includes ( 'Ran all test suites.' ) || stderr . includes ( 'failed' ) ) {
38+ throw new Error ( `Components were not transformed using AOT.\STDERR:\n\n${ stderr } ` ) ;
39+ }
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments