我有最新版本的WebStorm(10.0.4)。今天我想在我的项目中包含业力,所以我安装了Python并运行:
npm install -g karma
npm install karma
npm install karma-jasmine
npm install karma-chrome-launcher
npm install karma-phantomjs-launcher
我尝试了两个不同的配置文件,一个用于我的项目和一个超级基本配置,但两者都抛出相同的错误。这是基本配置:
// Karma configuration
// Generated on Fri Jul 17 2015 14:05:46 GMT+0200 (Mitteleuropäische Sommerzeit)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'test/**/*Spec.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
})
}
然后我创建了一个新的“Karma”运行配置,但是当我点击运行时,它说:
"C:\Program Files\nodejs\node.exe" "C:\Program Files (x86)\JetBrains\WebStorm 10.0.4\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js" --karmaPackageDir=C:\workspace\full_ui\node_modules\karma --configFile=C:\workspace\full_ui\tests\karma.conf_messages.js --browsers=Chrome
C:\Program Files (x86)\JetBrains\WebStorm 10.0.4\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js:10
server.start(cliOptions);
^
TypeError: undefined is not a function
at Object.<anonymous> (C:\Program Files (x86)\JetBrains\WebStorm 10.0.4\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js:10:8)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Process finished with exit code 1
我真的不知道是什么原因导致了这个问题。我错过了安装的任何内容吗?我之前从未使用过业力,所以我可能会在某处出现一些基本错误,但我无法弄清楚是什么。
答案 0 :(得分:12)
我认为这可能是由于最近9天前对karma lib的更新造成的。
https://github.com/karma-runner/karma/commits/master/lib/server.js
可能是intellijServer.js现在已经过时,需要更改。我通过更新intellijServer.js(直到intellij修复它)来实现它的工作:
var cli = require('./intellijCli.js')
, Server = cli.requireKarmaModule('lib/server.js')
, cliOptions = { configFile: require.resolve('./intellij.conf.js') };
var browsers = cli.getBrowsers();
if (browsers != null) {
cliOptions.browsers = browsers;
}
var server=new Server(cliOptions);
server.start();
// Prevent karma server from being an orphan process.
// For example, if WebStorm is killed using SIGKILL, karma server will still be alive.
// When WebStorm is terminated, karma server's standard input is closed automatically.
process.stdin.resume();
process.stdin.on('close', function () {
// terminating orphan process
process.exit(123);
});
一旦我的服务器位工作,我得到了另一个问题没有“框架:jasmine”的提供者!(但这似乎是影响我的一个单独的无关问题,因为我没有&#39;完全设置业力)。 这解决了:
npm install karma-jasmine --save-dev
npm install karma-chrome-launcher --save-dev
接着是
npm install