@@ -438,7 +438,8 @@ async function initializeApplication(
438
438
await writeTestFiles ( buildOutput . files , buildOptions . outputPath ) ;
439
439
440
440
// We need to add this to the beginning *after* the testing framework has
441
- // prepended its files.
441
+ // prepended its files. The output path is required for each since they are
442
+ // added later in the test process via a plugin.
442
443
const polyfillsFile : FilePattern = {
443
444
pattern : `${ outputPath } /polyfills.js` ,
444
445
included : true ,
@@ -454,31 +455,33 @@ async function initializeApplication(
454
455
watched : false ,
455
456
} ;
456
457
458
+ karmaOptions . basePath = outputPath ;
459
+
457
460
karmaOptions . files ??= [ ] ;
458
461
if ( options . scripts ?. length ) {
459
462
// This should be more granular to support named bundles.
460
463
// However, it replicates the behavior of the Karma Webpack-based builder.
461
464
karmaOptions . files . push ( {
462
- pattern : `${ outputPath } / scripts.js` ,
465
+ pattern : `scripts.js` ,
463
466
watched : false ,
464
467
type : 'js' ,
465
468
} ) ;
466
469
}
467
470
468
471
karmaOptions . files . push (
469
472
// Serve global setup script.
470
- { pattern : `${ outputPath } / ${ mainName } .js` , type : 'module' , watched : false } ,
473
+ { pattern : `${ mainName } .js` , type : 'module' , watched : false } ,
471
474
// Serve all source maps.
472
- { pattern : `${ outputPath } / *.map` , included : false , watched : false } ,
475
+ { pattern : `*.map` , included : false , watched : false } ,
473
476
// These are the test entrypoints.
474
- { pattern : `${ outputPath } / spec-*.js` , type : 'module' , watched : false } ,
477
+ { pattern : `spec-*.js` , type : 'module' , watched : false } ,
475
478
) ;
476
479
477
480
if ( hasChunkOrWorkerFiles ( buildOutput . files ) ) {
478
481
karmaOptions . files . push (
479
482
// Allow loading of chunk-* files but don't include them all on load.
480
483
{
481
- pattern : `${ outputPath } / {chunk,worker}-*.js` ,
484
+ pattern : `{chunk,worker}-*.js` ,
482
485
type : 'module' ,
483
486
included : false ,
484
487
watched : false ,
@@ -488,7 +491,7 @@ async function initializeApplication(
488
491
489
492
if ( options . styles ?. length ) {
490
493
// Serve CSS outputs on page load, these are the global styles.
491
- karmaOptions . files . push ( { pattern : `${ outputPath } / *.css` , type : 'css' , watched : false } ) ;
494
+ karmaOptions . files . push ( { pattern : `*.css` , type : 'css' , watched : false } ) ;
492
495
}
493
496
494
497
const parsedKarmaConfig : Config & ConfigOptions = await karma . config . parseConfig (
0 commit comments