无法安装Karma-PhantomJs和Karma-Jasmine

时间:2015-07-12 21:36:03

标签: node.js phantomjs karma-jasmine

我正在尝试为我的应用创建测试,并尝试正确设置karma.conf.js。这个文件是

karma.conf.js

// Karma configuration
// http://karma-runner.github.io/0.12/config/configuration-file.html
// Generated on 2015-07-12 using
// generator-karma 1.0.0

module.exports = function(config) {
  'use strict';

  config.set({
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // base path, that will be used to resolve files and exclude
    basePath: '',

    // testing framework to use (jasmine/mocha/qunit/...)
    // as well as any additional frameworks (requirejs/chai/sinon/...)
    frameworks: [
      "jasmine"
    ],

    // list of files / patterns to load in the browser
    files: [ "./lib/*.js",
             "./public/js/*.js",
             "./spec/*.js",
             "./node_modules/**/*.js"

            ],

    // list of files / patterns to exclude
    exclude: [
    ],

    // web server port
    port: 8080,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: [
      "Chrome"
    ],

    // Which plugins to enable
    plugins: [
      "karma-phantomjs-launcher",
      "karma-jasmine"
    ],

    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false,

    colors: true,

    // level of logging
    // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_INFO,

    // Uncomment the following lines if you are using grunt's server to run the tests
    // proxies: {
    //   '/': 'http://localhost:9000/'
    // },
    // URL root prevent conflicts with the site root
    // urlRoot: '_karma_'
  });
};

我的package.json是这样的:

的package.json

{
  "name": "Project",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.13.1",
    "nodemon": "^1.3.7"
  },
  "devDependencies": {
    "grunt-karma": "*",
    "karma": "^0.12.37",
    "karma-jasmine": "^0.3.6",
    "karma-phantomjs-launcher": "^0.2.0"
  }
}

运行时

karma start karma.conf.js

我收到以下错误消息:

WARN [plugin]: Cannot find plugin "karma-phantomjs-launcher".
  Did you forget to install it ?
  npm install karma-phantomjs-launcher --save-dev
WARN [plugin]: Cannot find plugin "karma-jasmine".
  Did you forget to install it ?
  npm install karma-jasmine --save-dev
/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');

所以我按照说明操作:

npm install karma-jasmine --save-dev

npm install karma-phantomjs-launcher --save-dev

但我继续收到原始错误消息。我完全没有这个想法。有什么帮助吗?

0 个答案:

没有答案