Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs - error to run unit test in official tutorial

Hi I am following this tutorial of angular , but by running the following command, test.bat. I get this error and not very well may be due.

"Can not load script, it is not registered! Perhaps you are missing some plugin"

I followed all the steps of this tutorial, I think I miss the pluggins. I have a folder in the root of the application called node_modules, where are all these pluggins

     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

My 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'
}

})}

Anyone can help me?

thanks

like image 868
Kaken Avatar asked Nov 01 '13 12:11

Kaken


1 Answers

You need to add the missing plugin to the karma config plugins section:

plugins : [
  'karma-junit-reporter',
  'karma-chrome-launcher',
  'karma-firefox-launcher',
  'karma-jasmine'
],

Or simply remove this plugin section and karma will load all plugins it finds. (It's ok to do this if you don't have too many plugins)

Edit:

Just cloned and installed the test project. Here are the installed dependencies:

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

It looks to me that you dont have phantomjs installed.

like image 190
bekite Avatar answered Oct 21 '22 14:10

bekite