[6a3a178] | 1 | # karma-source-map-support
|
---|
| 2 |
|
---|
| 3 | [![Greenkeeper badge](https://badges.greenkeeper.io/tschaub/karma-source-map-support.svg)](https://greenkeeper.io/)
|
---|
| 4 |
|
---|
| 5 | Karma plugin for inline sourcemap support.
|
---|
| 6 |
|
---|
| 7 | ## Motivation
|
---|
| 8 |
|
---|
| 9 | When loading Browserify bundles with inline source maps (via [`karma-browserify`](https://www.npmjs.com/package/karma-browserify)), the stack traces in Chrome don't mention the original modules. This plugin uses [`source-map-support`](https://www.npmjs.com/package/source-map-support) to improve the situation.
|
---|
| 10 |
|
---|
| 11 | ## Use
|
---|
| 12 |
|
---|
| 13 | Install the plugin with `npm`:
|
---|
| 14 |
|
---|
| 15 | npm install karma-source-map-support
|
---|
| 16 |
|
---|
| 17 | Configure Karma to load the plugin as a framework:
|
---|
| 18 |
|
---|
| 19 | ```js
|
---|
| 20 | module.exports = function(config) {
|
---|
| 21 | config.set({
|
---|
| 22 | frameworks: ['source-map-support']
|
---|
| 23 | // additional settings here ...
|
---|
| 24 | });
|
---|
| 25 | };
|
---|
| 26 | ```
|
---|
| 27 |
|
---|
| 28 | ## Example
|
---|
| 29 |
|
---|
| 30 | The config settings below are a complete example using Mocha and Browserify with source map support:
|
---|
| 31 |
|
---|
| 32 | ```js
|
---|
| 33 | module.exports = function(config) {
|
---|
| 34 | config.set({
|
---|
| 35 | frameworks: ['browserify', 'source-map-support', 'mocha'],
|
---|
| 36 | files: [
|
---|
| 37 | 'src/**/*.test.js'
|
---|
| 38 | ],
|
---|
| 39 | preprocessors: {
|
---|
| 40 | 'src/**/*.test.js': ['browserify']
|
---|
| 41 | },
|
---|
| 42 | browsers: ['PhantomJS'],
|
---|
| 43 | singleRun: false,
|
---|
| 44 | browserify: {
|
---|
| 45 | debug: true // include inline source maps
|
---|
| 46 | }
|
---|
| 47 | });
|
---|
| 48 | };
|
---|
| 49 | ```
|
---|
| 50 |
|
---|
| 51 | Sample stack trace without this plugin:
|
---|
| 52 | ```
|
---|
| 53 | AssertionError: case 2: expected [ 0, 0.6666666666666666 ] to deeply equal [ 0, 0.5 ]
|
---|
| 54 | at Function.assert.deepEqual (http://localhost:9876/absolute/var/folders/6m/3grlt52x7w3047wy0n6j7dr00000gn/T/2d4c510ad9122153a42db199d1cc8e9553208184.browserify:1848:32)
|
---|
| 55 | at Context.<anonymous> (http://localhost:9876/absolute/var/folders/6m/3grlt52x7w3047wy0n6j7dr00000gn/T/2d4c510ad9122153a42db199d1cc8e9553208184.browserify:6061:14)
|
---|
| 56 | at callFn (http://localhost:9876/base/node_modules/mocha/mocha.js:4496:21)
|
---|
| 57 | at Test.Runnable.run (http://localhost:9876/base/node_modules/mocha/mocha.js:4489:7)
|
---|
| 58 | at Runner.runTest (http://localhost:9876/base/node_modules/mocha/mocha.js:4892:10)
|
---|
| 59 | at http://localhost:9876/base/node_modules/mocha/mocha.js:4970:12
|
---|
| 60 | at next (http://localhost:9876/base/node_modules/mocha/mocha.js:4817:14)
|
---|
| 61 | at http://localhost:9876/base/node_modules/mocha/mocha.js:4827:7
|
---|
| 62 | at next (http://localhost:9876/base/node_modules/mocha/mocha.js:4766:23)
|
---|
| 63 | at http://localhost:9876/base/node_modules/mocha/mocha.js:4794:5
|
---|
| 64 | ```
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 | Sample stack trace with this plugin:
|
---|
| 68 | ```
|
---|
| 69 | AssertionError: case 2: expected [ 0, 0.6666666666666666 ] to deeply equal [ 0, 0.5 ]
|
---|
| 70 | at Function.assert.deepEqual (node_modules/chai/lib/chai/interface/assert.js:205:1)
|
---|
| 71 | at Context.<anonymous> (src/scenes/util/geom.test.js:27:1)
|
---|
| 72 | at callFn (http://localhost:9876/base/node_modules/mocha/mocha.js:4496:21)
|
---|
| 73 | at Test.Runnable.run (http://localhost:9876/base/node_modules/mocha/mocha.js:4489:7)
|
---|
| 74 | at Runner.runTest (http://localhost:9876/base/node_modules/mocha/mocha.js:4892:10)
|
---|
| 75 | at http://localhost:9876/base/node_modules/mocha/mocha.js:4970:12
|
---|
| 76 | at next (http://localhost:9876/base/node_modules/mocha/mocha.js:4817:14)
|
---|
| 77 | at http://localhost:9876/base/node_modules/mocha/mocha.js:4827:7
|
---|
| 78 | at next (http://localhost:9876/base/node_modules/mocha/mocha.js:4766:23)
|
---|
| 79 | at http://localhost:9876/base/node_modules/mocha/mocha.js:4794:5
|
---|
| 80 | ```
|
---|