@@ -102,7 +102,17 @@ function setupUnitTestBuild(config, env, webpack) {
102102 config . module . rule ( 'css' ) . include . add ( runnerPath ) ;
103103 config . module . rule ( 'xml' ) . include . add ( runnerPath ) ;
104104 config . module . rule ( 'js' ) . include . add ( runnerPath ) ;
105- const filesRegex = getKarmaTestsRegex ( webpack ) ;
105+ const defaultTsConfig = webpack . Utils . project . getProjectFilePath ( 'tsconfig.spec.json' ) ;
106+ const testTsEntryPath = join ( webpack . Utils . platform . getEntryDirPath ( ) , 'test.ts' ) ;
107+ const testJsEntryPath = join ( webpack . Utils . platform . getEntryDirPath ( ) , 'test.js' ) ;
108+ const tsConfigPath = env . testTsConfig || ( require ( 'fs' ) . existsSync ( defaultTsConfig ) ? defaultTsConfig : undefined ) ;
109+ if ( tsConfigPath ) {
110+ config . when ( config . module . rules . has ( 'ts' ) , ( config ) => config . module . rule ( 'ts' ) . uses . get ( 'ts-loader' ) . options ( merge ( config . module . rule ( 'ts' ) . uses . get ( 'ts-loader' ) . get ( 'options' ) , { configFile : tsConfigPath } ) ) ) ;
111+ config . when ( config . plugins . has ( 'AngularWebpackPlugin' ) , ( config ) => config . plugin ( 'AngularWebpackPlugin' ) . tap ( ( args ) => {
112+ args [ 0 ] = merge ( args [ 0 ] , { tsconfig : tsConfigPath } ) ;
113+ return args [ 0 ] ;
114+ } ) ) ;
115+ }
106116
107117 config . plugin ( 'DefinePlugin' ) . tap ( ( args ) => {
108118 args [ 0 ] = merge ( args [ 0 ] , {
@@ -128,9 +138,10 @@ function setupUnitTestBuild(config, env, webpack) {
128138 . clear ( )
129139 . add ( '@nativescript/core/globals/index.js' )
130140 . add ( '@nativescript/core/bundle-entry-points' )
131- . add ( '@nativescript/unit-test-runner/app/bundle-app' )
141+ // .add('@nativescript/unit-test-runner/app/bundle-app')
142+ . add ( require ( 'fs' ) . existsSync ( testTsEntryPath ) ? testTsEntryPath : testJsEntryPath )
132143 // .add('@nativescript/unit-test-runner/app/entry')
133- . add ( entryPath ) ;
144+ // .add(entryPath);
134145 if ( webpack . Utils . platform . getPlatformName ( ) === 'android' ) {
135146 config . entry ( 'bundle' )
136147 . add ( '@nativescript/core/ui/frame' )
0 commit comments