karma-jspm icon indicating copy to clipboard operation
karma-jspm copied to clipboard

How to add System into Karma

Open peteringram0 opened this issue 7 years ago • 8 comments

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)

peteringram0 avatar Oct 18 '16 09:10 peteringram0

You haven't mentioned versions of karma, or karma-jspm, or posted your karma.conf file...

togakangaroo avatar Nov 06 '16 17:11 togakangaroo

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
	    },
	});
};

peteringram0 avatar Feb 13 '17 18:02 peteringram0

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.*

ffflabs avatar Feb 15 '17 17:02 ffflabs

@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 avatar Feb 15 '17 19:02 peteringram0

@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.

ffflabs avatar Feb 22 '17 14:02 ffflabs

@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 avatar Mar 02 '17 11:03 ValeryIvanov

@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

ffflabs avatar Mar 24 '17 22:03 ffflabs

There's an open PR #187 that solves this issue

ffflabs avatar Mar 24 '17 23:03 ffflabs