@@ -13,32 +13,40 @@ const COVERAGE_ENABLED = !!process.env['COVERAGE'];
1313// true by default
1414const TEXT_COVERAGE_ENABLED = COVERAGE_ENABLED && ! process . env [ 'NO_TEXT_COVERAGE' ] ;
1515
16- const GEN_DIRECTORY = path . join ( __dirname , '..' , '..' , '..' ) ;
16+ const GEN_DIRECTORY = path . join ( __dirname , '..' , '..' ) ;
1717const ROOT_DIRECTORY = path . join ( GEN_DIRECTORY , '..' , '..' , '..' ) ;
18-
1918const browsers = DEBUG_ENABLED ? [ 'Chrome' ] : [ 'ChromeHeadless' ] ;
2019
2120const coverageReporters = COVERAGE_ENABLED ? [ 'coverage' ] : [ ] ;
2221const coveragePreprocessors = COVERAGE_ENABLED ? [ 'coverage' ] : [ ] ;
2322const commonIstanbulReporters = [ { type : 'html' } , { type : 'json-summary' } ] ;
24- const istanbulReportOutputs = TEXT_COVERAGE_ENABLED ? [ { type : 'text' } , ...commonIstanbulReporters ] : commonIstanbulReporters ;
23+ const istanbulReportOutputs =
24+ TEXT_COVERAGE_ENABLED ? [ { type : 'text' } , ...commonIstanbulReporters ] : commonIstanbulReporters ;
2525
26- const UNIT_TESTS_FOLDER = path . join ( ROOT_DIRECTORY , 'test' , 'unittests' , 'front_end' ) ;
27- const TEST_SOURCES = path . join ( UNIT_TESTS_FOLDER , '**/*.ts' ) ;
26+ const UNIT_TESTS_ROOT_FOLDER = path . join ( ROOT_DIRECTORY , 'test' , 'unittests' ) ;
27+ const UNIT_TESTS_FOLDERS = [
28+ path . join ( UNIT_TESTS_ROOT_FOLDER , 'front_end' ) ,
29+ ] ;
30+ const TEST_SOURCES = UNIT_TESTS_FOLDERS . map ( folder => path . join ( folder , '**/*.ts' ) ) ;
2831
2932// To make sure that any leftover JavaScript files (e.g. that were outputs from now-removed tests)
3033// aren't incorrectly included, we glob for the TypeScript files instead and use that
3134// to instruct Mocha to run the output JavaScript file.
32- const TEST_FILES = glob . sync ( TEST_SOURCES ) . map ( fileName => {
33- const jsFile = fileName . replace ( / \. t s $ / , '.js' ) ;
34- const generatedJsFile = path . join ( __dirname , path . relative ( UNIT_TESTS_FOLDER , jsFile ) ) ;
35-
36- if ( ! fs . existsSync ( generatedJsFile ) ) {
37- throw new Error ( `Test file ${ fileName } is not included in a BUILD.gn and therefore will not be run.` ) ;
38- }
35+ const TEST_FILES =
36+ TEST_SOURCES
37+ . map ( source => {
38+ return glob . sync ( source ) . map ( fileName => {
39+ const jsFile = fileName . replace ( / \. t s $ / , '.js' ) ;
40+ const generatedJsFile = path . join ( __dirname , path . relative ( UNIT_TESTS_ROOT_FOLDER , jsFile ) ) ;
41+ if ( ! fs . existsSync ( generatedJsFile ) ) {
42+ throw new Error ( `Test file ${ fileName } is not included in a BUILD.gn and therefore will not be run.` ) ;
43+ }
44+
45+ return generatedJsFile ;
46+ } ) ;
47+ } )
48+ . flat ( ) ;
3949
40- return generatedJsFile ;
41- } ) ;
4250
4351const TEST_FILES_SOURCE_MAPS = TEST_FILES . map ( fileName => `${ fileName } .map` ) ;
4452
@@ -49,14 +57,16 @@ module.exports = function(config) {
4957 files : [
5058 ...TEST_FILES . map ( pattern => ( { pattern, type : 'module' } ) ) ,
5159 ...TEST_FILES_SOURCE_MAPS . map ( pattern => ( { pattern, served : true , included : false } ) ) ,
52- { pattern : TEST_SOURCES , served : true , included : false } ,
60+ ... TEST_SOURCES . map ( source => ( { pattern : source , served : true , included : false } ) ) ,
5361 { pattern : path . join ( GEN_DIRECTORY , 'front_end/Images/*.{svg,png}' ) , served : true , included : false } ,
5462 { pattern : path . join ( GEN_DIRECTORY , 'front_end/**/*.css' ) , served : true , included : false } ,
5563 { pattern : path . join ( GEN_DIRECTORY , 'front_end/**/*.js' ) , served : true , included : false } ,
5664 { pattern : path . join ( GEN_DIRECTORY , 'front_end/**/*.js.map' ) , served : true , included : false } ,
5765 { pattern : path . join ( GEN_DIRECTORY , 'front_end/**/*.mjs' ) , served : true , included : false } ,
5866 { pattern : path . join ( GEN_DIRECTORY , 'front_end/**/*.mjs.map' ) , served : true , included : false } ,
5967 { pattern : path . join ( ROOT_DIRECTORY , 'front_end/**/*.ts' ) , served : true , included : false } ,
68+ { pattern : path . join ( GEN_DIRECTORY , 'inspector_overlay/**/*.js' ) , served : true , included : false } ,
69+ { pattern : path . join ( GEN_DIRECTORY , 'inspector_overlay/**/*.js.map' ) , served : true , included : false } ,
6070 ] ,
6171
6272 reporters : [
0 commit comments