2016-10-04 9 views
1

カルマを使ってjsテストケースを実行しようとしています。しかし、常にプラグインが見つかりません。そして、面白い部分はここで私の他の同僚のためにカルマ - プラグインが見つかりません

を正常に動作し、同じ設定ファイルであるログです:

$ karma start karma.conf.js 
04 10 2016 17:51:24.755:ERROR [plugin]: Cannot find plugin "karma-babel-preprocessor". 
    Did you forget to install it? 
    npm install karma-babel-preprocessor --save-dev 
04 10 2016 17:51:24.769:ERROR [plugin]: Cannot find plugin "karma-mocha". 
    Did you forget to install it? 
    npm install karma-mocha --save-dev 
04 10 2016 17:51:24.778:ERROR [plugin]: Cannot find plugin "karma-chrome-launcher". 
    Did you forget to install it? 
    npm install karma-chrome-launcher --save-dev 
04 10 2016 17:51:24.791:ERROR [preprocess]: Can not load "babel", it is not registered! 
    Perhaps you are missing some plugin? 
/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9 
     throw error('No provider for "' + name + '"!'); 
    ^

Error: No provider for "framework:mocha"! (Resolving: framework:mocha) 
    at error (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:22:12) 
    at Object.parent.get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9:13) 
    at get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:54:19) 
    at /usr/local/lib/node_modules/karma/lib/server.js:143:20 
    at Array.forEach (native) 
    at Server._start (/usr/local/lib/node_modules/karma/lib/server.js:142:21) 
    at invoke (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15) 
    at Server.start (/usr/local/lib/node_modules/karma/lib/server.js:103:18) 
    at Object.exports.run (/usr/local/lib/node_modules/karma/lib/cli.js:280:26) 
    at Object.<anonymous> (/usr/local/lib/node_modules/karma/bin/karma:3:23) 
    at Module._compile (module.js:409:26) 
    at Object.Module._extensions..js (module.js:416:10) 
    at Module.load (module.js:343:32) 
    at Function.Module._load (module.js:300:12) 
    at Function.Module.runMain (module.js:441:10) 
    at startup (node.js:139:18) 

はここkarma.config.js

// Karma configuration 
// Generated on Thu Jan 28 2016 12:33:59 GMT-0500 (EST) 

module.exports = function(config) { 
    config.set({ 

    // base path that will be used to resolve all patterns (eg. files, exclude) 
    basePath: '', 

    plugins: [ 
     'karma-babel-preprocessor', 
     'karma-mocha', 
     'karma-chrome-launcher', 
    ], 

    // frameworks to use 
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 
    frameworks: ['mocha', 'chai'], 


    // list of files/patterns to load in the browser 
    files: [ 
     '.venv/lib/python2.7/site-packages/xstatic/pkg/jquery/data/jquery.min.js', 
     '.venv/lib/python2.7/site-packages/horizon/static/horizon/js/horizon.js', 
     '.venv/lib/python2.7/site-packages/horizon/static/horizon/js/horizon.quota.js', 
     '.venv/lib/python2.7/site-packages/horizon/static/horizon/js/horizon.instances.js', 
     'myapp/static/comp/js/pricing.js', 
     'myapp/test/js/**/*.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: { 
     'myapp/test/js/**/*.js': ['babel'] 
    }, 

    babelPreprocessor: { 
     options: { 
     presets: ['es2015'], 
     sourceMap: 'inline' 
     }, 
     filename: function (file) { 
     return file.originalPath.replace(/\.js$/, '.es5.js'); 
     }, 
     sourceFileName: function (file) { 
     return file.originalPath; 
     } 
    }, 


    // 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: true, 

    // Concurrency level 
    // how many browser should be started simultaneous 
    concurrency: Infinity 
    }) 
} 

ここでは、パッケージです.json

{ 
    "name": "comp_horizon", 
    "version": "1.0.0", 
    "description": "some description", 
    "main": "index.js", 
    "scripts": { 
    "test": "node node_modules/karma/bin/karma start karma.conf.js --single-run" 
    }, 
    "repository": { 
    "type": "git", 
    "url": "git+https://github.com/priverepo/comp_horizon.git" 
    }, 
    "author": "", 
    "license": "ISC", 
    "bugs": { 
    "url": "https://github.com/priverepo/comp_horizon/issues" 
    }, 
    "homepage": "https://github.com/priverepo/comp_horizon#readme", 
    "devDependencies": { 
    "babel": "^6.3.26", 
    "babel-core": "^6.4.5", 
    "babel-loader": "^6.2.1", 
    "babel-preset-es2015": "^6.3.13", 
    "chai": "^3.4.1", 
    "karma": "^0.13.19", 
    "karma-babel-preprocessor": "^6.0.1", 
    "karma-chai": "^0.1.0", 
    "karma-chrome-launcher": "^2.0.0", 
    "karma-coverage": "0.3.1", 
    "karma-mocha": "^1.2.0", 
    "mocha": "^3.1.0", 
    "webpack": "^1.12.12", 
    "webpack-bundle-tracker": "0.0.93" 
    }, 
    "dependencies": { 
    "babel-polyfill": "^6.3.14" 
    } 
} 

can not fileプラグインエラーのために、私はそのプラグインをインストールしています。しかし、エラーは依然として続く。例えば"karma-babel-preprocessor"というプラグインが見つからないため、npmはkarma-babel-preprocessor --save-devをインストールしました。それは見つけた。しかし、まだエラーが発生します。

ありがとう

答えて

-1

テストを実行する前にnpm installを実行してみましたか?あなたの同僚は、グローバルにインストールされたnpmパッケージを持っていますか?私のグローバルパッケージキャッシュ(Windows 10)はC:\ Users \\ AppData \ Roaming \ npmです。もしあなたがインストールしていないものがインストールされていたら、それをグローバルにインストールしてください(npm installに-gオプションを使用してください)。そしてプロジェクトディレクトリにnpm installを実行してから、再度テストを実行してください。

関連する問題