[英]Angularjs - error to run unit test in official tutorial
您好我遵循這個角度教程,但通過運行以下命令test.bat。 我得到這個錯誤,並不是很好。
“無法加載腳本,它沒有注冊!也許你錯過了一些插件”
我按照本教程的所有步驟操作,我想我錯過了插件。 我在應用程序的根目錄中有一個名為node_modules的文件夾,其中包含所有這些插件
karma
karma-chrome-launcher
karma-coffee-preprocessor
karma-firefox-launcher
karma-html2js-preprocessor
karma-jasmine
karma-junit-reporter
karma-phantomjs-launcher
karma-RequireJS
karma-script-launcher
我的karma.config
module.exports = function(config){
config.set({
basePath : '../',
files : [
'app/lib/angular/angular.js',
'app/lib/angular/angular-*.js',
'test/lib/angular/angular-mocks.js',
'app/js/**/*.js',
'test/unit/**/*.js'
],
exclude: ['app/lib/angular/angular-scenario.js'],
autoWatch : true,
frameworks: ['jasmine'],
browsers : ['C:/Program Files/Google/Chrome/Application/chrome.exe'],
plugins : [
'karma-junit-reporter',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine'
],
junitReporter : {
outputFile: 'test_out/unit.xml',
suite: 'unit'
}
})}
有人可以幫幫我嗎?
謝謝
您需要將缺少的插件添加到karma配置插件部分:
plugins : [
'karma-junit-reporter',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine'
],
或者只是刪除這個插件部分,業力將加載它找到的所有插件。 (如果沒有太多的插件,可以這樣做)
編輯:
剛剛克隆並安裝了測試項目。 以下是已安裝的依賴項:
karma
karma-html2js-preprocessor
karma-phantomjs-launcher
karma-chrome-launcher
karma-jasmine
karma-requirejs
karma-coffee-preprocessor
karma-junit-reporter
karma-script-launcher
karma-firefox-launcher
karma-ng-scenario
phantomjs
在我看來,你沒有安裝phantomjs。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.