我们的网站正在使用 Aurelia 导航骨架 typescript 入门套件。我能够使用 jasmine 和 karma 运行单元测试,但我无法让 karma-coverage 发挥作用。有没有办法让它工作?
我试图使用以下 karma.conf.js 文件让它在 skeleton-typescript 项目中工作。
module.exports = function(config) {
config.set({
basePath: './',
frameworks: ['systemjs', 'jasmine'],
systemjs: {
configFile: 'config.js',
config: {
paths: {
"*": "*",
"src/*": "src/*",
"typescript": "node_modules/typescript/lib/typescript.js",
"systemjs": "node_modules/systemjs/dist/system.js",
'system-polyfills': 'node_modules/systemjs/dist/system-polyfills.js',
'es6-module-loader': 'node_modules/es6-module-loader/dist/es6-module-loader.js'
},
packages: {
'test/unit': {
defaultExtension: 'ts'
},
'src': {
defaultExtension: 'ts'
}
},
transpiler: 'typescript',
typescriptOptions : {
"module": "amd",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
},
serveFiles: [
'src/**/*.*',
'jspm_packages/**/*.js'
]
},
files: [
'test/unit/setup.ts',
'test/unit/*.ts'
],
exclude: [],
preprocessors: { 'src/**/*.ts': ['coverage']},
reporters: ['progress', 'coverage'],
coverageReporter: {
type : 'html',
dir : 'coverage/'
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
最佳答案
我建议使用 cli并使用 au new
。该模板自去年以来已更新并提供选项。您可以默认设置 Karma。
关于javascript - 如何使用 Aurelia 和 typescript 获得 karma 覆盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42696974/