karma-jspm
karma-jspm copied to clipboard
How to add System into Karma
Hey,
Im getting the following error:
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
ReferenceError: Can't find variable: System
at blob:http://localhost:9876/06e2d137-ede4-4078-92da-28f33c3e83e4:2
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 22 ERROR (0.016 secs / 0 secs)
You haven't mentioned versions of karma, or karma-jspm, or posted your karma.conf file...
Karma 1.4.1 Karma-JSPM 2.2.0 JSPM 0.17.0-beta.39
module.exports = function (config) {
config.set({
autoWatch: false,
singleRun: true,
browserNoActivityTimeout: 130000,
frameworks: ['jspm', 'jasmine-ajax', 'jasmine'],
jspm: {
config: './src/jspm.config.js',
loadFiles: [
'./src/test.spec.js',
],
serveFiles: [
'./src/**/!(*spec).js'
]
},
proxies: {
'/src/': '/base/src/',
'/': 'http://placehold.it/1x1', // stops the 404 issue
'/jspm_packages/': '/src/jspm_packages/'
},
browsers: ['PhantomJS'],
reporters: ['spec'],
specReporter: {
maxLogLines: 5, // limit number of lines logged per test
suppressErrorSummary: true, // do not print error summary
suppressFailed: false, // do not print information about failed tests
suppressPassed: false, // do not print information about passed tests
suppressSkipped: true, // do not print information about skipped tests
showSpecTiming: true // print the time elapsed for each spec
},
});
};
This plugin/adapter already injects SystemJS to the files array. The problem lies in the removal of system-polyfills, which causes an error in karma-jspm and -much worse- causes the main SystemJS script to error, because it uses Promise and PhantomJS doesn't support promises yet.
Since this adapter will always add system.src.js as the first served file, there's no room to inject a promise polyfill into it.
TL;DR: we're stuck with jspm 0.17.0-beta.32 for the time being, until @guybedford decides to re-add system polyfills, or phantomjs 2.5 is released (it allegedly support promises), or this adapter includes its own promise polyfill before system.src.js in the files array.
The latter would have to be done after checking the existance of system-polyfills, to determine if we're dealing with SystemJS v20.*
@amenadiel This post is very useful thanks. Looking over everything happening with SystemJS i'm not convinced it will be added back in. Hopefully like you said it gets added back in or this plugin will change so that a polyfill can be injected.
@peteringram0 perhaps switching from Phantom to either SlimerJS or NightmareJS woudl help. Those two support promises natively.
I couldn't make my tests pass with jasmine and nightmarejs, but it ran just like PhantomJS was supposed to run.
@amenadiel what error was shown when you tried NightmareJS?
I also tried that but it just says Error: Failed to fetch
whatever file is under test.
@ValeryIvanov I didn't dig much deeper into Nightmare. The tests that were passing under phantom failed on it, and I had no intention to debug them
There's an open PR #187 that solves this issue