Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix sourcemap support for karma
Browse files Browse the repository at this point in the history
Remove karma-source-map-support dependency, it is no longer needed.
The karma-sourcemap-loader module will handle source maps for us.

Add the sourcemap preprocessor to the test files as well so the
test file line numbers also match.

Instead of the devtool option in the webpack test config, use
the SourceMapDevToolPlugin. This will also generate source
maps on files with a .ts extension.

Fixes #15
  • Loading branch information
Floris Bernard committed Jul 25, 2016
1 parent 50a73db commit 80441f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions config/webpack.config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ var path = require('path');
module.exports = function()
{
return {
/**
* Inline source maps, generated by TypeScript compiler, will be used.
*/
devtool: 'inline-source-map',

resolve: {
extensions: ['', '.ts', '.js']
},
Expand Down Expand Up @@ -51,5 +46,12 @@ module.exports = function()
}
]
},
// we use this instead of the devtool option, to force sourcemap generation for .ts files
plugins: [
new webpack.SourceMapDevToolPlugin({
filename: null,
test: /\.(t|j|cs)s($|\?)/i
})
]
};
};
5 changes: 3 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(config)

// List of test frameworks we will use. Most of them are provided by separate packages (adapters).
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai', 'source-map-support'],
frameworks: ['mocha', 'chai'],

// Entry point / test environment builder is also written in TypeScript.
files: [
Expand All @@ -27,7 +27,8 @@ module.exports = function(config)
'coverage'
],
'./test/**/*.ts': [
'webpack'
'webpack',
'sourcemap'
]
},

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"karma-mocha": "^1.1.1",
"karma-phantomjs-launcher": "^1.0.0",
"karma-remap-istanbul": "^0.1.1",
"karma-source-map-support": "^1.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"marked": "^0.3.5",
Expand Down

0 comments on commit 80441f9

Please sign in to comment.