简体   繁体   中英

Karma Jasmine NPM config

karma config errors

I'm trying to configure my test environment, and getting the following bugs when I try to run karma.

karma start
06 10 2015 13:13:36.859:DEBUG [plugin]: Loading plugin karma-jasmine.
06 10 2015 13:13:36.917:DEBUG [karma]: List of files has changed, trying to execute
06 10 2015 13:13:36.918:WARN [karma]: No captured browser, open http://localhost:9876/
06 10 2015 13:13:36.922:DEBUG [watcher]: Watching ".../representative-summary/node_modules/angular"
06 10 2015 13:13:36.922:DEBUG [watcher]: Watching ".../representative-summary/node_modules/angular-resource"
06 10 2015 13:13:36.923:DEBUG [watcher]: Watching ".../representative-summary/spec"
06 10 2015 13:13:36.927:WARN [launcher]: Can not load "karma-chrome-launcher", it is not registered!
  Perhaps you are missing some plugin?
06 10 2015 13:13:36.927:WARN [launcher]: Can not load "karma-firefox-launcher", it is not registered!
  Perhaps you are missing some plugin?
06 10 2015 13:13:36.928:WARN [launcher]: Can not load "karma-safari-launcher", it is not registered!
  Perhaps you are missing some plugin?
06 10 2015 13:13:36.928:WARN [launcher]: Can not load "karma-ie-launcher", it is not registered!
  Perhaps you are missing some plugin?
06 10 2015 13:13:36.928:WARN [launcher]: Can not load "karma-phantomjs-launcher", it is not registered!
  Perhaps you are missing some plugin?

karma.conf.js

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

        basePath: '',
        frameworks: ['jasmine'],
        files: [
            {pattern: 'node_modules/angular/*.js', included: true},
            {pattern: 'node_modules/angular-resource/*.js', included: true},
            {pattern: 'spec/*.spec.js', included: true}
        ],
        reporters: ['progress'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_DEBUG,
            //config.LOG_INFO,
        autoWatch: true,
        browsers: [
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-safari-launcher',
            'karma-phantomjs-launcher'
        ],
        plugins: ['karma-jasmine'],
        singleRun: false
    })
};

I'm on OSX Yosemite 10.10.5, and yes there is a standalone test in there "expect true to be true" just to get it up and running by itself. The app I am writing is Angular, but I haven't touched any of the tests for that yet. I want just the basic test runner to be working right first.

Any help would be great. Thanks.

Browsers in karma come in English format ( Chrome , Firefox , PhantomJS ), not as their respective plugin names. The plugins just have to be installed with npm install --save .

ALSO: Karma will "magically" load any library in your node_modules directory starting with karma- , so you don't need to declare plugins: at all in your configuration file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM