I am trying to get my unittests to work in phantomJS using Karma and Jasmine. Unittests are written in Typescript, as well as in source files.
Tests work fine in Chrome, Safari, and Firefox , but don't work in PhantomJS. Error:
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
Error: (SystemJS) eval@[native code]
tryCatchReject@/poc/node_modules/systemjs/dist/system-polyfills.src.js:1188:34
runContinuation1@/poc/node_modules/systemjs/dist/system-polyfills.src.js:1147:18
when@/poc/node_modules/systemjs/dist/system-polyfills.src.js:935:20
run@/poc/node_modules/systemjs/dist/system-polyfills.src.js:826:17
_drain@/poc/node_modules/systemjs/dist/system-polyfills.src.js:102:22
drain@/poc/node_modules/systemjs/dist/system-polyfills.src.js:67:15
Evaluating /poc/src/components/button/button.js
Error loading /poc/test/components/button/button.spec.ts
I tried connecting the phantomjs debugger, but it does not cause any errors, so I am a bit stuck here.
Karma configuration:
module.exports = function (config) {
config.set({
customLaunchers: {
'PhantomJS_custom': {
base: 'PhantomJS',
options: {
windowName: 'my-window',
settings: {
webSecurityEnabled: false
}
},
flags: ['--load-images=true'],
debug: true
}
},
basePath: '../',
frameworks: ['systemjs', 'jasmine'],
plugins: [
'karma-systemjs',
'karma-jasmine',
'karma-coverage',
'karma-remap-istanbul',
'karma-typescript-preprocessor',
'karma-safari-launcher',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher'
],
preprocessors: {
'src/**/*.ts': ['typescript', 'coverage']
},
files: [
'node_modules/phantomjs-polyfill/bind-polyfill.js',
'test/**/button.spec.ts',
'testutils/**/*.ts'
],
systemjs: {
configFile: 'config/system.conf.js',
config: {
packages: {
'src': {
defaultExtension: 'js'
},
'test': {
defaultExtension: 'ts'
},
'testutils': {
defaultExtension: 'ts'
}
},
transpiler: "typescript"
},
serveFiles: [
'src/**/*.ts',
'test/**/button.spec.ts',
'testutils/**/*.ts'
]
},
exclude: [],
coverageReporter: {
reporters: [
{
type: 'json',
dir: 'coverage',
subdir: '.',
file: 'report.json'
}
]
},
remapIstanbulReporter: {
src: 'coverage/report.json',
reports: {
lcovonly: 'coverage/lcov.info',
html: 'coverage/html/report'
}
},
reporters: [
'progress',
'coverage',
'karma-remap-istanbul'
],
typescriptPreprocessor: {
options: {
inlineSourceMap: true,
inlineSources: true,
"outDir": ".tmp/",
sourceMap: false,
noImplicitUseStrict: true,
target: 'ES5',
module: 'commonjs',
concatenateOutput: false
}
},
port: 9876,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
concurrency: Infinity,
captureTimeout: 60000,
browserDisconnectTimeout: 20000000000,
browserDisconnectTolerance: 0,
browserNoActivityTimeout: 1000000000
})
};