@@ -16,71 +16,73 @@ const testsVariants: [suitName: string, baseUrl: string | undefined][] = [
1616] ;
1717
1818describeBuilder ( buildApplication , APPLICATION_BUILDER_INFO , ( harness ) => {
19- for ( const [ suitName , baseUrl ] of testsVariants ) {
20- describe ( suitName , ( ) => {
21- beforeEach ( async ( ) => {
22- await harness . modifyFile ( 'tsconfig.json' , ( content ) => {
23- const tsconfig = JSON . parse ( content ) ;
24- tsconfig . compilerOptions . baseUrl = baseUrl ;
25-
26- return JSON . stringify ( tsconfig ) ;
27- } ) ;
28- } ) ;
29-
30- it ( 'uses a provided TypeScript file' , async ( ) => {
31- harness . useTarget ( 'build' , {
32- ...BASE_OPTIONS ,
33- polyfills : [ 'src/polyfills.ts' ] ,
19+ describe ( 'Option: polyfills' , ( ) => {
20+ for ( const [ suitName , baseUrl ] of testsVariants ) {
21+ describe ( suitName , ( ) => {
22+ beforeEach ( async ( ) => {
23+ await harness . modifyFile ( 'tsconfig.json' , ( content ) => {
24+ const tsconfig = JSON . parse ( content ) ;
25+ tsconfig . compilerOptions . baseUrl = baseUrl ;
26+
27+ return JSON . stringify ( tsconfig ) ;
28+ } ) ;
3429 } ) ;
3530
36- const { result } = await harness . executeOnce ( ) ;
31+ it ( 'uses a provided TypeScript file' , async ( ) => {
32+ harness . useTarget ( 'build' , {
33+ ...BASE_OPTIONS ,
34+ polyfills : [ 'src/polyfills.ts' ] ,
35+ } ) ;
3736
38- expect ( result ?. success ) . toBe ( true ) ;
39-
40- harness . expectFile ( 'dist/browser/polyfills.js' ) . toExist ( ) ;
41- } ) ;
37+ const { result } = await harness . executeOnce ( ) ;
4238
43- it ( 'uses a provided JavaScript file' , async ( ) => {
44- await harness . writeFile ( 'src/polyfills.js' , `console.log('main');` ) ;
39+ expect ( result ?. success ) . toBe ( true ) ;
4540
46- harness . useTarget ( 'build' , {
47- ...BASE_OPTIONS ,
48- polyfills : [ 'src/polyfills.js' ] ,
41+ harness . expectFile ( 'dist/browser/polyfills.js' ) . toExist ( ) ;
4942 } ) ;
5043
51- const { result } = await harness . executeOnce ( ) ;
44+ it ( 'uses a provided JavaScript file' , async ( ) => {
45+ await harness . writeFile ( 'src/polyfills.js' , `console.log('main');` ) ;
5246
53- expect ( result ?. success ) . toBe ( true ) ;
47+ harness . useTarget ( 'build' , {
48+ ...BASE_OPTIONS ,
49+ polyfills : [ 'src/polyfills.js' ] ,
50+ } ) ;
5451
55- harness . expectFile ( 'dist/browser/polyfills.js' ) . content . toContain ( `console.log("main")` ) ;
56- } ) ;
52+ const { result } = await harness . executeOnce ( ) ;
53+
54+ expect ( result ?. success ) . toBe ( true ) ;
5755
58- it ( 'fails and shows an error when file does not exist' , async ( ) => {
59- harness . useTarget ( 'build' , {
60- ...BASE_OPTIONS ,
61- polyfills : [ 'src/missing.ts' ] ,
56+ harness . expectFile ( 'dist/browser/polyfills.js' ) . content . toContain ( `console.log("main")` ) ;
6257 } ) ;
6358
64- const { result, logs } = await harness . executeOnce ( { outputLogsOnFailure : false } ) ;
59+ it ( 'fails and shows an error when file does not exist' , async ( ) => {
60+ harness . useTarget ( 'build' , {
61+ ...BASE_OPTIONS ,
62+ polyfills : [ 'src/missing.ts' ] ,
63+ } ) ;
6564
66- expect ( result ?. success ) . toBe ( false ) ;
67- expect ( logs ) . toContain (
68- jasmine . objectContaining ( { message : jasmine . stringMatching ( 'Could not resolve' ) } ) ,
69- ) ;
65+ const { result, logs } = await harness . executeOnce ( { outputLogsOnFailure : false } ) ;
7066
71- harness . expectFile ( 'dist/browser/polyfills.js' ) . toNotExist ( ) ;
72- } ) ;
67+ expect ( result ?. success ) . toBe ( false ) ;
68+ expect ( logs ) . toContain (
69+ jasmine . objectContaining ( { message : jasmine . stringMatching ( 'Could not resolve' ) } ) ,
70+ ) ;
7371
74- it ( 'resolves module specifiers in array' , async ( ) => {
75- harness . useTarget ( 'build' , {
76- ...BASE_OPTIONS ,
77- polyfills : [ 'zone.js' , 'zone.js/testing' ] ,
72+ harness . expectFile ( 'dist/browser/polyfills.js' ) . toNotExist ( ) ;
7873 } ) ;
7974
80- const { result } = await harness . executeOnce ( ) ;
81- expect ( result ?. success ) . toBeTrue ( ) ;
82- harness . expectFile ( 'dist/browser/polyfills.js' ) . toExist ( ) ;
75+ it ( 'resolves module specifiers in array' , async ( ) => {
76+ harness . useTarget ( 'build' , {
77+ ...BASE_OPTIONS ,
78+ polyfills : [ 'zone.js' , 'zone.js/testing' ] ,
79+ } ) ;
80+
81+ const { result } = await harness . executeOnce ( ) ;
82+ expect ( result ?. success ) . toBeTrue ( ) ;
83+ harness . expectFile ( 'dist/browser/polyfills.js' ) . toExist ( ) ;
84+ } ) ;
8385 } ) ;
84- } ) ;
85- }
86+ }
87+ } ) ;
8688} ) ;
0 commit comments