0
角度cliでカバレッジレポートを生成しようとしています。しかし、私は次のエラーが続いています。これが私のKarma.confのcliエラーか問題なのかどうかは分かりません。 ng test
/npm test
正常に実行...コードカバレッジオプションと何か関係がありますか?Angular Cli-SyntaxError:「インポート」と「エクスポート」は「sourceType:module」としか表示されません。
Error: Module build failed: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (3:0)
at Parser.pp$5.raise (C:\Development\source\\node_modules\babylon\lib\index.js:4443:13)
at Parser.pp$1.parseStatement (C:\Development\source\\node_modules\babylon\lib\index.js:1875:16)
at Parser.parseStatement (C:\Development\source\\node_modules\babylon\lib\index.js:5795:22)
at Parser.pp$1.parseBlockBody (C:\Development\source\\node_modules\babylon\lib\index.js:2262:21)
at Parser.pp$1.parseTopLevel (C:\Development\source\\node_modules\babylon\lib\index.js:1772:8)
at Parser.parse (C:\Development\source\\node_modules\babylon\lib\index.js:1667:17)
at Object.parse (C:\Development\source\\node_modules\babylon\lib\index.js:7163:37)
at Instrumenter.instrumentSync (C:\Development\source\\node_modules\istanbul-lib-instrument\dist\instrumenter.js:121:31)
at Instrumenter.instrument (C:\Development\source\\node_modules\istanbul-lib-instrument\dist\instrumenter.js:176:32)
at Object.module.exports (C:\Development\source\\node_modules\istanbul-instrumenter-loader\index.js:25:25),Module build failed: SyntaxError: 'import
' and 'export' may appear only with 'sourceType: module' (2:0)
at Parser.pp$5.raise (C:\Development\source\\node_modules\babylon\lib\index.js:4443:13)
at Parser.pp$1.parseStatement (C:\Development\source\\node_modules\babylon\lib\index.js:1875:16)
at Parser.parseStatement (C:\Development\source\\node_modules\babylon\lib\index.js:5795:22)
at Parser.pp$1.parseBlockBody (C:\Development\source\\node_modules\babylon\lib\index.js:2262:21)
at Parser.pp$1.parseTopLevel (C:\Development\source\\node_modules\babylon\lib\index.js:1772:8)
at Parser.parse (C:\Development\source\\node_modules\babylon\lib\index.js:1667:17)
at Object.parse (C:\Development\source\\node_modules\babylon\lib\index.js:7163:37)
at Instrumenter.instrumentSync (C:\Development\source\\node_modules\istanbul-lib-instrument\dist\instrumenter.js:121:31)
at Instrumenter.instrument (C:\Development\source\\node_modules\istanbul-lib-instrument\dist\instrumenter.js:176:32)
at Object.module.exports (C:\Development\source\\node_modules\istanbul-instrumenter-loader\index.js:25:25)
at Compiler.compiler.plugin (C:\Development\source\\node_modules\@angular\cli\plugins\karma-webpack-throw-error.js:10:23)
at Compiler.applyPlugins (C:\Development\source\\node_modules\tapable\lib\Tapable.js:61:14)
at Watching._done (C:\Development\source\\node_modules\webpack\lib\Compiler.js:91:17)
at onCompiled (C:\Development\source\\node_modules\webpack\lib\Compiler.js:50:17)
at C:\Development\source\\node_modules\webpack\lib\Compiler.js:480:13
at next (C:\Development\source\\node_modules\tapable\lib\Tapable.js:138:11)
at Compiler.<anonymous> (C:\Development\source\\node_modules\webpack\lib\CachePlugin.js:62:5)
at Compiler.applyPluginsAsyncSeries (C:\Development\source\\node_modules\tapable\lib\Tapable.js:142:13)
at C:\Development\source\\node_modules\webpack\lib\Compiler.js:477:10
at Compilation.applyPluginsAsyncSeries (C:\Development\source\\node_modules\tapable\lib\Tapable.js:131:46)
at self.applyPluginsAsync.err (C:\Development\source\\node_modules\webpack\lib\Compilation.js:640:19)
at next (C:\Development\source\\node_modules\tapable\lib\Tapable.js:138:11)
at Compilation.<anonymous> (C:\Development\source\\node_modules\webpack\lib\ProgressPlugin.js:122:5)
at Compilation.applyPluginsAsyncSeries (C:\Development\source\\node_modules\tapable\lib\Tapable.js:142:13)
at self.applyPluginsAsync.err (C:\Development\source\\node_modules\webpack\lib\Compilation.js:631:11)
at next (C:\Development\source\\node_modules\tapable\lib\Tapable.js:138:11)
私karma.conf今日は同じ問題を襲ったこの
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-chrome-launcher'),
require('@angular/cli/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly', 'json'],
fixWebpackSourcePaths: true
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};