Skip to content

Commit c7d80ac

Browse files
committed
fix: Try to fix karma to run with modules
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent e736687 commit c7d80ac

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

tests/karma.config.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,20 @@ module.exports = function(config) {
9999
}
100100

101101
files.push('core/js/tests/html-domparser.js');
102-
files.push('dist/core-main.js');
103-
files.push('dist/core-files_fileinfo.js');
104-
files.push('dist/core-files_client.js');
105-
files.push('dist/core-systemtags.js');
102+
files.push({ pattern: 'dist/core-main.mjs', type: 'module' });
103+
files.push({ pattern: 'dist/core-common.mjs', type: 'module' });
104+
files.push('dist/core-legacy.js');
105+
files.push({ pattern: 'dist/core-files_fileinfo.mjs', type: 'module' });
106+
files.push({ pattern: 'dist/core-files_client.mjs', type: 'module' });
107+
files.push({ pattern: 'dist/core-systemtags.mjs', type: 'module' });
106108

107109
// core mocks
108110
files.push('core/js/tests/specHelper.js');
109111

110112
// add core modules files
111113
for (i = 0; i < coreModule.modules.length; i++) {
112114
srcFile = corePath + coreModule.modules[i];
113-
files.push(srcFile);
115+
files.push({ pattern: srcFile, type: srcFile.endsWith('mjs') ? 'module' : 'js' });
114116
if (enableCoverage) {
115117
preprocessors[srcFile] = 'coverage';
116118
}
@@ -134,7 +136,7 @@ module.exports = function(config) {
134136
}
135137

136138
// add source files/patterns
137-
files = files.concat(app.srcFiles || []);
139+
files.push(...app.srcFiles.map((file) => ({ pattern: file, type: file.endsWith('mjs') ? 'module' : 'js' })));
138140
// add test files/patterns
139141
files = files.concat(app.testFiles || []);
140142
if (enableCoverage) {
@@ -166,6 +168,14 @@ module.exports = function(config) {
166168
served: true
167169
});
168170

171+
// include server CSS
172+
files.push({
173+
pattern: 'dist/*.css',
174+
watched: true,
175+
included: true,
176+
served: true
177+
});
178+
169179
// Allow fonts
170180
files.push({
171181
pattern: 'core/fonts/*',
@@ -174,6 +184,14 @@ module.exports = function(config) {
174184
served: true
175185
});
176186

187+
files.push({
188+
pattern: 'dist/chunks/*',
189+
type: 'module',
190+
watched: false,
191+
included: false,
192+
served: true
193+
});
194+
177195
console.log(files)
178196

179197
config.set({
@@ -186,6 +204,10 @@ module.exports = function(config) {
186204
// list of files / patterns to load in the browser
187205
files: files,
188206

207+
mime: {
208+
'text/javascript': ['js','mjs'],
209+
},
210+
189211
// list of files to exclude
190212
exclude: [],
191213

@@ -196,7 +218,7 @@ module.exports = function(config) {
196218
'/base/core/css/images/': 'http://localhost:9876/base/core/css/images/',
197219
'/actions/': 'http://localhost:9876/base/core/img/actions/',
198220
'/base/core/fonts/': 'http://localhost:9876/base/core/fonts/',
199-
'/svg/': '../core/img/'
221+
'/svg/': '../core/img/',
200222
},
201223

202224
// test results reporter to use

0 commit comments

Comments
 (0)