sshev / karma-remap-coverage

Karma reporter that maps coverage to original non transpiled code (TypeScript, ES6/7, etc)
MIT License
35 stars 4 forks source link

Cannot get it work with webpack. #8

Open uhrb opened 8 years ago

uhrb commented 8 years ago

Hi! I am trying to make it work with webpack. Is it possible? https://github.com/l0nley/karma-remap-coverage-example `
D:\Work\TAJI\karma>gulp test
[21:08:32] Using gulpfile D:\Work\TAJI\karma\gulpfile.js
[21:08:32] Starting 'test'...
ts-loader: Using typescript@2.0.6
28 10 2016 21:08:35.309:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
28 10 2016 21:08:35.311:INFO [launcher]: Launching browser PhantomJS2 with unlimited concurrency
28 10 2016 21:08:35.343:INFO [launcher]: Starting browser PhantomJS2
28 10 2016 21:08:36.908:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#xDwAy96smi2sBAIDAAAA with id 50031128
PhantomJS 2.1.1 (Windows 8 0.0.0) LOG: 'WARNING: Tried to load angular more than once.'

PhantomJS 2.1.1 (Windows 8 0.0.0) LOG: 'WARNING: Tried to load angular more than once.'

PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 1 of 1 SUCCESS (0.072 secs / 0.002 secs)
[Error: Could not find source map for: "D:\Work\TAJI\karma\src\core.ts"]
28 10 2016 21:08:40.759:ERROR [karma]: [TypeError: Cannot read property 'text' of undefined]
TypeError: Cannot read property 'text' of undefined
at D:\Work\TAJI\karma\node_modules\istanbul\lib\report\html.js:288:53
at Array.forEach (native) As i can understand, there is problem with source map, which is inlined. One more thing - it looks like remap somehow breaks reporting. Is it possible at all use this library with webpack and typescript?

noherczeg commented 7 years ago

Try this:

Create a file called tests.webpack.js:

// This file is an entry point for angular tests
// Avoids some weird issues when using webpack + angular.

import 'angular';
import 'angular-mocks/angular-mocks';

var testsContext = require.context('.', true, /.spec$/);
testsContext.keys().forEach(testsContext);

In your karma.conf.js file set it as an entry point:

        files: [
            // Grab all files in the app folder that contain .spec.
            'src/tests.webpack.js'
        ],