我正在尝试开始在我的项目中进行测试。我看到很多帖子说我需要将我的karma.conf.js文件从angular-cli/plugins/karma
更新为@angular-cli/plugins/karma
。在我引用angular-cli
的任何地方我将@
符号放在它前面。这并没有解决我的错误。
我错过了什么?
以下是错误:
06 06 2017 11:04:09.268:ERROR [config]: Error in config file!
{ Error: Cannot find module '@angular-cli/plugins/karma'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at module.exports (/.../karma.conf.js:12:7)
at Object.parseConfig (.../node_modules/karma/lib/config.js:410:5)
at new Server (.../node_modules/karma/lib/server.js:56:20)
at Promise (.../node_modules/@angular/cli/tasks/test.js:34:33)
at Class.run (.../node_modules/@angular/cli/tasks/test.js:15:16)
at Class.run (.../node_modules/@angular/cli/commands/test.js:101:25)
at Class.Command.validateAndRun (.../node_modules/@angular/cli/ember-cli/lib/models/command.js:128:15)
at .../node_modules/@angular/cli/ember-cli/lib/cli/cli.js:92:22
at tryCatch (.../node_modules/rsvp/dist/lib/rsvp/-internal.js:216:12)
at invokeCallback (.../node_modules/rsvp/dist/lib/rsvp/-internal.js:231:13)
at .../node_modules/rsvp/dist/lib/rsvp/then.js:29:16
at flush (.../node_modules/rsvp/dist/lib/rsvp/asap.js:85:5) code: 'MODULE_NOT_FOUND' }
这是我的配置文件
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('@angular-cli/plugins/karma'),
require('karma-htmlfile-reporter')
],
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular-cli']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
mime: {
'text/x-typescript': ['ts','tsx']
},
reporters: ['progress', 'karma-remap-istanbul', 'html'],
htmlReporter: {
outputFile: 'tests/units.html',
// Optional
pageTitle: 'Unit Tests for Frontend',
subPageTitle: 'Should always be passing.',
groupSuites: true,
useCompactStyle: true,
useLegacyStyle: true
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
答案 0 :(得分:2)
删除配置条目
angularCli: {
environment: 'dev'
},
更多信息https://github.com/angular/angular-cli/wiki/stories-rc.0-update