Ich habe die letzten paar Tage mit der Berichterstattung Berichterstattung arbeiten gearbeitet und ich habe ein Problem getroffen, das ich nicht lösen konnte. Der Stack-Trace Ich erhalte, mit ein paar Zeilen von Debug-Code umgibt, istAngular 2 + Karma + Karma-jspm + Karma-Abdeckung + Typoskript Bericht PhantomJS Fehler
15 07 2016 14:41:53.413:DEBUG [middleware:source-files]: Requesting /jspm_packages/npm/[email protected]/browser.js/
15 07 2016 14:41:53.413:DEBUG [middleware:source-files]: Fetching /jspm_packages/npm/[email protected]/browser.js
15 07 2016 14:41:53.415:DEBUG [proxy]: proxying request - /jspm_packages/npm/[email protected]/browser.js to localhost:9876
15 07 2016 14:41:53.417:DEBUG [middleware:source-files]: Requesting /base/jspm_packages/npm/[email protected]/browser.js/
15 07 2016 14:41:53.417:DEBUG [middleware:source-files]: Fetching /home/administrator/assist-2.0/client/jspm_packages/npm/[email protected]/browser.js
15 07 2016 14:41:53.419:DEBUG [web-server]: serving: /home/administrator/assist-2.0/client/jspm_packages/npm/[email protected]/browser.js
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
Error: (SystemJS) /home/administrator/assist-2.0/client/jspm_packages/system.src.js:3047:137
/home/administrator/assist-2.0/client/jspm_packages/system.src.js:3756:33
/home/administrator/assist-2.0/client/jspm_packages/system.src.js:4251:37
/home/administrator/assist-2.0/client/jspm_packages/system.src.js:1508:27
/home/administrator/assist-2.0/client/jspm_packages/system.src.js:2738:28
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:2998:23
eval code
[email protected][native code]
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:1544:18
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:3723:20
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:3281:36
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:3124:28
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:3491:17
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:774:32
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:972:36
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:631:11
[email protected]/home/administrator/assist-2.0/client/jspm_packages/system.src.js:677:24
/home/administrator/assist-2.0/client/jspm_packages/system.src.js:493:30
[email protected]/home/administrator/assist-2.0/client/node_modules/zone.js/dist/zone.js:323:34
[email protected]/home/administrator/assist-2.0/client/node_modules/zone.js/dist/zone.js:230:54
/home/administrator/assist-2.0/client/node_modules/zone.js/dist/zone.js:206:40
Evaluating http://localhost:9876/dist/src/components/widgets/nested-table/nested-table.component.js
Error loading http://localhost:9876/dist/tests/unit/components/nested-table.spec.js
PhantomJS 2.1.1 (Linux 0.0.0): Executed 0 of 0 ERROR (1.095 secs/0 secs)
15 07 2016 14:41:53.436:DEBUG [karma]: Run complete, exiting.
15 07 2016 14:41:53.437:DEBUG [launcher]: Disconnecting all browsers
15 07 2016 14:41:53.441:DEBUG [launcher]: Process PhantomJS2 exited with code 0
15 07 2016 14:41:53.442:DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-88547336
15 07 2016 14:41:53.449:DEBUG [launcher]: Finished all browsers
karma.conf.js
module.exports = function(config) {
config.set({
frameworks: ['jspm', 'jasmine'],
basePath: '.',
files: [
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/reflect-metadata/Reflect.js',
'node_modules/es6-shim/es6-shim.js',
'jspm_packages/system-polyfills.js'
],
jspm: {
loadFiles: [
'dist/tests/**/*.js',
],
serveFiles: [
'dist/src/**/*.js',
// 'src/**/*.ts'
]
},
proxies: {
// '/src/': '/base/src/',
'/dist/src/': '/base/dist/src/',
'/dist/tests/': '/base/dist/tests/',
'/jspm_packages/': '/base/jspm_packages/',
},
port: 9876,
logLevel: config.LOG_INFO,
colors: true,
autoWatch: true,
browsers: [
// 'PhantomJS',
'PhantomJS2',
],
plugins: [
'karma-jasmine',
'karma-jspm',
'karma-phantomjs-launcher',
'karma-phantomjs2-launcher',
'karma-junit-reporter',
'karma-coverage',
'karma-sourcemap-loader',
// 'karma-typescript-preprocessor'
],
reporters: [
'coverage',
'junit',
'dots',
],
junitReporter: {
outputDir: '.',
outputFile: "./reports/client-test-results.xml",
useBrowserName: false
},
preprocessors: {
'dist/src/**/!(*.spec).js!(.map)': [
'sourcemap',
// 'typescript',
'coverage'
],
// 'src/**/*.ts': [
// 'sourcemap',
// 'typescript',
// 'coverage',
// ],
},
coverageReporter: {
dir: 'reports',
subdir: 'coverage',
includeAllSources: true,
reporters: [
{
type: 'json',
file: 'coverage.json'
},
// {
// type: 'cobertura',
// file: 'coverage.xml'
// },
// {
// type: 'html',
// subdir: 'coverage/html'
// }
],
instrumenterOptions: {
istanbul: {
noCompact: true
}
}
},
// typescriptPreprocessor: {
// options: {
// inlineSourceMap: true,
// inlineSources: true,
// "target": "es5",
// "module": "system",
// "sourceMap": true,
// "emitDecoratorMetadata": true,
// "experimentalDecorators": true,
// "removeComments": false,
// "noImplicitAny": false,
// },
// transformPath: function(path) {
// return path.replace(/\.ts$/, '.js');
// }
// },
singleRun: true
})
};
verschachtelten table.spec.ts
import {NestedTableComponent} from '../../../src/components/widgets/nested-table/nested-table.component';
import {beforeEach, describe, expect, it} from '@angular/core/testing';
import {DEBUG_VIEW_TEST_DATA, DEBUG_VIEW_TEST_HEADERS} from '../../../src/db/mockdata';
import { ImmutableMatchers } from '../helpers/jasmine-immutable-matchers';
describe('Nested Table Component',() => {
let ntable, data, headers;
beforeEach(function() {
jasmine.addMatchers(ImmutableMatchers);
ntable = new NestedTableComponent();
data = DEBUG_VIEW_TEST_DATA[0].data;
headers = DEBUG_VIEW_TEST_HEADERS[0].headers;
});
it('should return an array of keys',() => {
expect(ntable.keys(data)).toEqualImmutable(data.keySeq());
});
it('should calculate the widths of columns',() => {
let expected = {
"Element Property": 4,
"Key": 2,
"Property Value": 2,
"Last Refresh": 2,
"Element Definition": 2
}
expect(ntable.getColWidths(headers)).toEqual(expected);
});
});
Wenn ich ändern, um die Präprozessoren
preprocessors: {
'dist/src/!(*.spec).js!(.map)': [
'sourcemap',
// 'typescript',
'coverage'
],
// 'src/**/*.ts': [
// 'sourcemap',
// 'typescript',
// 'coverage',
// ],
},
Ich erhalte den Stack-Trace nicht, und er gibt mir Deckung, aber offensichtlich nicht auf meinen anderen Komponenten und so. Dies scheint ein Problem beim Laden des SystemJS-Moduls zu sein, aber ich kann nicht herausfinden, was vor sich geht, oder ob das sogar das eigentliche Problem ist.
Die Tests laufen gut, wenn ich die Abdeckung aus der Reporterliste entferne.
Ich habe auch versucht, karma-typescript-preprocessor (siehe die auskommentierten Bits des Codes in karma.conf.js), und ich bekam einen Coverage-Bericht, aber die Quellkartendateien würden nicht korrekt zugeordnet, die ich konnte auch nicht herausfinden.
Hat jemand etwas Ähnliches erfahren und einen Weg gefunden, das Problem zu lösen?