gpt4 book ai didi

javascript - karma-remap-istanbul 正在生成源旁边的覆盖 html

转载 作者:行者123 更新时间:2023-11-28 04:59:12 27 4
gpt4 key购买 nike

我正在尝试为我的 Aurelia(+ webpack + TypeScript)网站设置单元测试。我的 karma.conf.js 如下所示(类似于 aurelia-navigation 骨架中所做的操作):

"use strict";
const path = require('path');

module.exports = function (config) {
config.set({
basePath: __dirname,
frameworks: ['jasmine'],
exclude: [],

files: [{
pattern: 'spec-bundle.js',
watched: false
} ],

preprocessors: {
'spec-bundle.js': ['coverage', 'webpack', 'sourcemap']
},

webpack: require('../webpack.config'),

coverageReporter: {
reporters: [
{
type: 'json',
subdir: '.',
file: 'coverage-final.json'
},
{
type: 'html',
dir: path.join(__dirname, 'coverage/'),
subdir: '.'
}
]
},

remapIstanbulReporter: {
src: path.join(__dirname, 'coverage/coverage-final.json'),
reports: {
html: path.join(__dirname, 'coverage/remapped/')
}
// ,
// timeoutNotCreated: 1000,
// timeoutNoMoreFiles: 1000
},

webpackServer: { noInfo: true },

reporters: ['mocha', 'coverage', 'karma-remap-istanbul'],

port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: [
// 'Chrome',
'SlimerJS'
],
singleRun: true
});


console.log(config);
};

我的文件夹结构如下:

Website
|-src
|-test
| |-coverage
| |-unit
| | |-*.spec.ts
| |-karma.conf.js
| |-spec.bundle.js //as given by aurelia-navigation skeleton
|-webpack.config.js

问题在于 karma-remap-istanbul 将覆盖率 html 转储到源旁边,而不是输出 test/coverage/remapped/ 中的所有内容。

我是否缺少任何配置?

最佳答案

尝试按如下方式更新 remapIstanbulReporter 属性。

    remapIstanbulReporter: {
src: path.join(__dirname, 'coverage/coverage-final.json'),
reports: {
html: 'test/coverage/remapped'
}

}

诀窍是在给出路径时,如果您输入'./',它将采用文件夹结构中文件位置的相对路径。

当您将路径指定为'folder/folderA/folderB'时,它将采用绝对路径。

关于javascript - karma-remap-istanbul 正在生成源旁边的覆盖 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42296192/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com