Gulp + Babel + Webpack + Karma:使用源映射进行堆栈跟踪

时间:2017-01-03 10:24:41

标签: angularjs gulp webpack karma-runner babeljs

在AngularJS 1项目中,我们使用Gulp使用webpack编译项目并使用Karma进行测试。我们无法让源图按预期工作。

我找到了明显的插件(https://www.npmjs.com/package/karma-sourcemap-loader),但这似乎只存在于调试业力测试时使用源图,而不是显示可用的堆栈跟踪。

我还发现https://www.npmjs.com/package/karma-source-map-support似乎是浏览器专有的。

我在这里遗漏了什么吗?有没有人得到这个工作?

附加信息:

这是不可用的输出(注意index.module.js,webpack编译文件,它有内联源图):

<p>

这就是我的业力配置的样子:

PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 629 of 629 (1 FAILED) (6.663 secs / 6.531 secs)
TOTAL: 1 FAILED, 628 SUCCESS

1) should A B not be A B
   TrajectDetails Controller _aMethod()
   Expected Object({ a: Object({ x: [ 'A', 'B' ] }) }) not to be Object({ materieel: Object({ x: [ 'A', 'B' ] }) }).
   .tmp/serve/app/index.module.js:93820:42

[11:02:26] 'test' errored after 9.37 s
[11:02:26] Error: Failed 1 tests.

Webpack配置是这样的:

var preprocessors = {};
pathSrcJs.forEach(function (path) {
    preprocessors[path] = ['babel', 'sourcemap'];
});
pathSrcHtml.forEach(function (path) {
    preprocessors[path] = ['ng-html2js'];
});

var configuration = {
    files: listFiles(),
    preprocessors: preprocessors,
    singleRun: true,
    colors: true,
    autoWatch: false,
    ngHtml2JsPreprocessor: {
        stripPrefix: conf.paths.src + '/',
        moduleName: 'xx-xx'
    },
    logLevel: 'INFO',
    frameworks: ['source-map-support', 'jasmine'],
    browsers: ['PhantomJS'],
    plugins: [
        'karma-phantomjs-launcher',
        'karma-coverage',
        'karma-jasmine',
        'karma-ng-html2js-preprocessor',
        'karma-spec-reporter',
        'karma-babel-preprocessor',
        'karma-sourcemap-loader',
        'karma-source-map-support'
    ],
    reporters: ['progress', 'spec'],
};

config.set(configuration);

0 个答案:

没有答案