Commit ef7ea53 1 parent 5123ff4 commit ef7ea53 Copy full SHA for ef7ea53
File tree 3 files changed +47
-1
lines changed
packages/angular_devkit/build_angular/src/builders/jest
tests/legacy-cli/e2e/tests/jest
3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ export default createBuilder(
85
85
tsConfig : options . tsConfig ,
86
86
polyfills : options . polyfills ?? [ 'zone.js' , 'zone.js/testing' ] ,
87
87
outputPath : testOut ,
88
- aot : false ,
88
+ aot : options . aot ,
89
89
index : false ,
90
90
outputHashing : OutputHashing . None ,
91
91
outExtension : 'mjs' , // Force native ESM.
Original file line number Diff line number Diff line change 32
32
"uniqueItems" : true
33
33
},
34
34
"default" : []
35
+ },
36
+ "aot" : {
37
+ "type" : " boolean" ,
38
+ "description" : " Run tests using Ahead of Time compilation." ,
39
+ "default" : false
35
40
}
36
41
},
37
42
"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