Closed metamatt closed 9 years ago
Here's a patch that works for my project. It does 3 things:
1) swap the order of loading adapter.js (which sets baseURL to match karma's webserver's /base path) and the client project's config.js
2) remove the separate import of es6-module-loader.js, which is now folded into system.js
3) remove the code to remove the .js suffix from module IDs before calling System.import
diff --git a/node_modules/karma-jspm/src/adapter.js b/node_modules/karma-jspm/src/adapter.js
index 3200a9f..64f3eaa 100644
--- a/node_modules/karma-jspm/src/adapter.js
+++ b/node_modules/karma-jspm/src/adapter.js
@@ -19,10 +19,6 @@
// Prevent immediately starting tests.
window.__karma__.loaded = function() {};
- function extractModuleName(fileName){
- return fileName.replace(/\.js$/, "");
- }
-
var promises = [];
if(!System){
@@ -46,7 +42,7 @@
// Load everything specified in loadFiles
for (var i = 0; i < karma.config.jspm.expandedFiles.length; i++) {
var modulePath = karma.config.jspm.expandedFiles[i];
- var promise = System['import'](extractModuleName(modulePath))
+ var promise = System['import'](modulePath)
['catch'](function(e){
setTimeout(function() {
throw e;
diff --git a/node_modules/karma-jspm/src/init.js b/node_modules/karma-jspm/src/init.js
index cda239e..8a77de7 100644
--- a/node_modules/karma-jspm/src/init.js
+++ b/node_modules/karma-jspm/src/init.js
@@ -92,10 +92,9 @@ module.exports = function(files, basePath, jspm, client) {
return packagesPath + fileName + '.js';
}
}
- files.unshift(createPattern(__dirname + '/adapter.js'));
files.unshift(createPattern(configPath));
+ files.unshift(createPattern(__dirname + '/adapter.js'));
files.unshift(createPattern(getLoaderPath('system')));
- files.unshift(createPattern(getLoaderPath('es6-module-loader')));
// Loop through all of jspm.load_files and do two things
// 1. Add all the files as "served" files to the files array
@metamatt can you make a PR to robertbaker/karma-jspm?
this fix works for the 1.* branch, but I hadn't luck applying it to the current master/beta branches
Updating to 2.0.1-beta.1fixed the baseURL issues for me, but now is giving me different errors that I believe are coming from it adding 'dist' in this path Uncaught Error: XHR error (404 Not Found) loading /Users/weston/Desktop/aur-fork/www/dist/src/app.js
. My karma.conf.js looks like this
jspm: {
// Edit this to your needs
loadFiles: ['src/**/*.js', 'test/unit/**/*.js'],
paths: {
'*': '*.js'
}
},
and my System.js config includes
paths: {
"*": "dist/*",
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
So I guess it's adding in the dist
to my path because of the System config? (excuse my ignorance, fairly new to Karma and JSPM/System.js.)
hitting this issue as well - similar issues to wwseleck
Same issue as @wwseleck the value "dist" is getting added to my path. I would have thought in jarma.conf.js setting a path override under jspm: {} would have fixed this issue, but it seems the path overrides are ignored.
https://github.com/Workiva/karma-jspm/pull/84 fixes this issue for me. You can test by using "karma-jspm": "git://github.com/JeroenVinke/karma-jspm#master",
in your package.json and running npm install
Thanks, the master
branch fixed this problem for me.
At this moment I'm running with SystemJS v0.19.4
and karma-jspm 2.0.1
I'm still getting the baseURL error:
Chrome 45.0.2454 (Windows 10 0.0.0) ERROR
Uncaught TypeError: baseURL should only be configured once and must be configured first.
at c:/Development/Projects/testApplication/src/Web/wwwroot/jspm_packages/system.src.js:1633
+1
This is happening to me as well. SystemJS v0.19.4
and karma-jspm 2.0.1
I found that if I comment out System.config({ baseURL: 'base' });
on line 18 of adapter.js, I am able to get my tests to run.
Confirmed, this is back now.
Same error here
It should be fixed in v0.19.5: https://github.com/systemjs/systemjs/issues/837
SystemJS 0.18.0 enforces that baseURL can only be set before other config, and thus karma-jspm's call to
System.config({ baseURL: 'base' })
provokes an error like