Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

karma v1.0.0: You need to include some adapter that implements __karma__.start method! #2194

Closed
SerkanSipahi opened this issue Jun 26, 2016 · 26 comments · Fixed by #2277 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132

Comments

@SerkanSipahi
Copy link

SerkanSipahi commented Jun 26, 2016

After upgrading our project from karma v0.13.22 to v.1.0.0 we get following error:
You need to include some adapter that implements __karma__.start method!

Here is a the repo: https://github.com/SerkanSipahi/app-decorators

Reproducing error:
git clone https://github.com/SerkanSipahi/app-decorators.git
cd app-decorators
// change in package.json karma to 1.0.0
make install
make compile
make test

Anyone have an idea What causes this error ?

@dignifiedquire
Copy link
Member

Thanks for the report, I think the problem is somewhere with karma-jspm. When I comment it out the error goes away. Might be some internals that changed that karma-jspm relied on.

@SerkanSipahi
Copy link
Author

SerkanSipahi commented Jun 26, 2016

@dignifiedquire thank you for the quick response. I will relate this issue to karma-jspm.

@hpurmann
Copy link
Contributor

hpurmann commented Jun 27, 2016

Unfortunately, it also breaks karma-sinon-chai (but there is an easy fix) kevicency/karma-sinon-chai#38

@RIAstar
Copy link

RIAstar commented Jun 29, 2016

The problem indeed seems to be with karma-jspm. I tracked it down to some duplicate file references in the globs on the files array.
See computmaxer/karma-jspm#162 (comment) for a workaround.

That said, the result of this duplicate file reference is that no files are loaded at all, including adapter.js, hence the message that the adapter has no start function, since there is no adapter to begin with.
So perhaps this could be a bug on the Karma side as well?
In any case, the fact that the file loading fails silently is not very nice.

@jgerigmeyer
Copy link

Not surprisingly, it breaks karma-chai-sinon (https://github.com/tubalmartin/karma-chai-sinon) as well.

@RIAstar
Copy link

RIAstar commented Jun 30, 2016

@jgerigmeyer : that's odd. I use karma-chai-sinon as well and don't have any issues with that (only with karma-jspm).

Versions I use:

  • "karma-chai-sinon": "^0.1.5"
  • "karma-mocha": "^1.1.1"

@SerkanSipahi
Copy link
Author

@jgerigmeyer do you use jspm in your project? if yes, can you share your setup?

@jgerigmeyer
Copy link

I am not using jspm. With this setup:

    "karma": "1.1.0",
    "karma-chai-sinon": "0.1.5"

I get the following:

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  You need to include some adapter that implements __karma__.start method!
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.024 secs / 0 secs)

If I remove chai-sinon from my karma frameworks setup, the tests run as expected.

@newdaveespionage
Copy link

newdaveespionage commented Jun 30, 2016

I'm running a similar configuration to @jgerigmeyer and experiencing the same outcome

While doing further digging, and attempting to reconfigure fallbacks, I've found that including 'chai' with karma-chai in the frameworks array also triggers the same error, while 'sinon' with karma-sinon does not.

In my package.json I'm using '*' for versions to ensure most current editions. If I roll-back to karma v0.13.22 this issue does not occur.

for reference, frameworks array differences in karma.conf.js:

Causes error indicated in this bug:
frameworks: ['requirejs', 'mocha', 'chai-sinon', 'jquery-chai', 'fixture'],
(edited, had mistyped chai-sinon as karma-chai-sinon)

This as well:
frameworks: ['requirejs', 'mocha', 'chai', 'sinon', 'jquery-chai', 'fixture'],

Runs tests (but tests fail due to lack of chai:
frameworks: ['requirejs', 'mocha', 'sinon', 'jquery-chai', 'fixture'],

@thepian
Copy link

thepian commented Jul 4, 2016

This is my config that doesn't work. Downgraded to 0.13.22

'use strict';

var path = require('path'),
    fs = require('fs'),
    pkg = require(path.join(__dirname,'./package.json')),
    minimist = require('minimist'),
    debug = require('debug')('karmaConfig');

var config = {
    frameworks: ['jasmine-jquery', 'jasmine', 'browserify'],
    browsers: ['Firefox'],
    reporters: ['progress','kjhtml'],

    colors: true,
    autoWatch: true,
    // logLevel: 'LOG_DEBUG',

    preprocessors: {
        '**/*.js':'eslint',
        'src/main/**/*.js':'browserify',
        'src/bower_components/*/index.js':'browserify'
    },
    plugins: [
        'karma-eslint',
        'karma-browserify',
        'karma-jasmine-jquery',
        'karma-jasmine',
        'karma-jasmine-html-reporter',
        'karma-chrome-launcher',
        'karma-firefox-launcher',
        'karma-phantomjs-launcher'
    ],
    eslint: {
        stopOnError: true,
        stopOnWarning: false,
        showWarnings: true,
        engine: {
            configFile: path.join(__dirname,'.eslintrc'),
            ignorePath: path.join(__dirname,'..','.eslintignore'),
            ignore: true
        }
    },
    browserify: pkg.browserify,
    files: [
        'src/bower_components/angular-mocks/angular-mocks.js',
        'src/bower_components/ui-angular/index.js',
        'src/bower_components/vendelbi-frontend/index.js',
        'src/bower_components/ui-angular/model/js/stubRestModel.js',
        'src/bower_components/vendelbi-frontend/useCaseModel/js/mockUseCaseModel.js',
        'src/main/mobizApp/mobizApp.js',
        'src/test/**/*.spec.js'
        /*,
        ,
        {
            pattern: 'src/test/fixtures/** /*.test-data.json',
            watched: true,
            served: true,
            included: false
        }
        */
    ]

};

module.exports = function(config) {
    var argv = minimist(process.argv.slice(2));
    config.set(adjustKarmaConfig({
        title: 'Mobiz',
        coverage: argv.coverage || config.coverage
    }));
};

function adjustKarmaConfig(opts) {
    config.basePath = __dirname;
    if (opts.coverage) {

    }
    config.files = (pkg['vendor.js'] || []).concat(config.files);
    config.browserify = {
        paths: config.browserify.paths,
        transform: config.browserify.transform.map(mapBrowserifyPlugins),
        debug: true // could be configurable
    };
    debug(config);
    return config;

    function mapBrowserifyPlugins(name) {
        switch (name) {
            case 'browserify-ng-html2js':
                return require(name)(pkg.ngHtml2JsPreprocessor);
        }
        return name;
    }
}

@dignifiedquire
Copy link
Member

@thepian try disabling the different plugins to see which one is throwing the issue, and file an issue on the respective repo please.

@otroboe
Copy link

otroboe commented Jul 4, 2016

Hello !

I have the same problem here, after hours of investigation :)

karma.conf.js

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

    config.set({
        autoWatch: true,
        singleRun: true,

        frameworks: ['jspm', 'jasmine'],

        files: [
            'node_modules/babel-polyfill/dist/polyfill.js'
        ],

        jspm: {
            config: 'app/config.js',
            loadFiles: [
                'spec/*.spec.js'
            ],
            serveFiles: [
                'app/utils/helpers.js'
            ]
        },

        proxies: {
            '/app/': '/base/app/',
            '/spec': '/base/spec',
            '/jspm_packages/': '/app/jspm_packages/'
        },

        browsers: ['PhantomJS'],

        reporters: ['spec']
    });
};

package.json

{
  "author": "",
  "license": "ISC",
  "name": "",
  "version": "0.0.1",
  "description": "",
  "main": "index.html",
  "dependencies": {},
  "devDependencies": {
    "babel-core": "^6.10.4",
    "babel-polyfill": "^6.9.1",
    "babel-preset-es2015": "^6.9.0",
    "gulp": "3.9.1",
    "gulp-eslint": "2.0.0",
    "gulp-livereload": "3.8.1",
    "gulp-open": "2.0.0",
    "gulp-print": "2.0.1",
    "gulp-webserver": "0.9.1",
    "jasmine": "^2.4.1",
    "jasmine-core": "^2.4.1",
    "jspm": "^0.16.39",
    "karma": "^0.13.22",
    "karma-babel-preprocessor": "^6.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jspm": "^2.1.1",
    "karma-phantomjs-launcher": "^1.0.1",
    "karma-spec-reporter": "0.0.26",
    "phantomjs": "^2.1.7"
  },
  "scripts": {
    "test": "jasmine-node spec/",
    "build": "jspm bundle main --inject",
    "dev": "jspm unbundle"
  },
  "jspm": {
    "directories": {
      "baseURL": "app"
    },
    "dependencies": {
      "jquery": "npm:jquery@^3.0.0",
      "json": "github:systemjs/plugin-json@^0.1.2",
      "lodash": "npm:lodash@^4.13.1"
    },
    "devDependencies": {
      "babel": "npm:babel-core@^5.8.24",
      "babel-runtime": "npm:babel-runtime@^5.8.24",
      "core-js": "npm:core-js@^1.1.4"
    }
  }
}

When I set karma version at 1.0.0, it is not working anymore, with this error:

04 07 2016 11:16:50.913:INFO [karma]: Karma v1.0.0 server started at http://localhost:9876/
04 07 2016 11:16:50.915:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
04 07 2016 11:16:50.924:INFO [launcher]: Starting browser PhantomJS
04 07 2016 11:16:51.138:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#EMpTLLeY3_QtYnUOAAAA with id 78592311
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
You need to include some adapter that implements karma.start method!

@newdaveespionage
Copy link

newdaveespionage commented Jul 5, 2016

Since both the karma plugins for Chai (karma-chai and karma-chai-sinon) didn't show hope of responses anytime soon (both are year+ in terms of any new dev or issue feedback), and I'm using RequireJS for our project, the webpack solutions for the sinon include didn't apply.

What I've done so far to resolve this issue is to add chai expect via a testUtils file (which I was already including)

EDIT: removed changes to test-main.js as chai was already included via other plugins

karma.conf.js

files: [
      'tests/helpers/testUtils.js',
      'tests/test-main.js',
]

testUtils.js

var expect = chai.expect;
window.expect = expect;

This appears to resolve the dependency issue and the karma start error, however, I feel dirty putting it on the window object. It's a more simple fix than updating every single test to include expect, which is used globally, so it seems to make sense.

@newdaveespionage
Copy link

newdaveespionage commented Jul 6, 2016

Due to deadlines, I couldn't press further than this, but combined with my above changes, I found that the core issue is that both karma-chai-sinon and karma-jquery-chai load chai directly, and that triggers the error in my scenario for this issue thread.

The other half of my solution (to restore access to chai-sinon) was to create a custom instance of karma-chai-sinon

karma-chai-sinon-custom.js

var path = require('path');

var createPattern = function(path) {
  return {pattern: path, included: true, served: true, watched: false};
};

var initChaiSinon = function(files) {
  files.unshift(createPattern(path.dirname(require.resolve('sinon-chai')) + '/sinon-chai.js'));
  var sinonPath = path.dirname(require.resolve('sinon')) + '/../pkg';
  files.unshift(createPattern(sinonPath + '/sinon.js'));
};

initChaiSinon.$inject = ['config.files'];
module.exports = {
   'framework:chai-sinon': ['factory', initChaiSinon]
};

and include it in karma.conf.js as follows:


    // Which plugins to enable
    plugins: [
      'karma-mocha',
      'karma-jquery-chai',
      'karma-fixture',
      'karma-html2js-preprocessor',
      'karma-spec-reporter',
      'karma-nyan-reporter',
      'karma-chrome-launcher',
      'karma-phantomjs-launcher',
      'karma-firefox-launcher',
      'karma-coverage',
      'karma-requirejs',
      // custom include here:
      require('./(your-path-to)/karma-chai-sinon-custom')
    ],

Specific to the original plugin (karma-chai-sinon) there was a lot of phantomjs fixing and preloading of libraries, which in the 1.0.0+ versions of karma appear to cause collisions that result in the test-runner failing out. This will probably be an issue for all Karma + Chai related plugins that auto-load chai as part of their routine. Same for any combination of plugins loading Sinon, as I experienced the same collision with karma-sinon and karma-chai-sinon on the Sinon-specific include (albeit that this is a negative test, as there aren't typically multiple sinon-plugins from what I've seen.)

@dignifiedquire
Copy link
Member

Released as 1.1.2

@otroboe
Copy link

otroboe commented Jul 26, 2016

It works for me ! Thanks a lot 👍

@samuv
Copy link

samuv commented Jul 26, 2016

it works for me too 👍

@ghost
Copy link

ghost commented Aug 11, 2016

👍

@aaron-zipnosis
Copy link

I'm still having issues with this. Everything should be updated.

  "devDependencies": {
    "chai": "^3.5.0",
    "karma": "^1.2.0",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^0.1.12",
    "karma-coffee-preprocessor": "^1.0.1",
    "karma-coverage": "^0.3.1",
    "karma-haml-attribute-concatenation-preprocessor": "^0.1.1",
    "karma-haml-preprocessor": "^0.1.0",
    "karma-mocha": "^0.1.10",
    "karma-ng-html2js-preprocessor": "^1.0.0",
    "karma-osx-reporter": "^0.2.1",
    "karma-phantomjs-launcher": "^1.0.1",
    "karma-sinon-chai": "^0.3.2",
    "mocha": "^2.5.3",
    "sinon": "^1.17.5"
  },

DEBUG [web-server]: serving: /Users/application/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /Users/application/node_modules/karma/static/karma.js
DEBUG [karma]: A browser has connected on socket /#pDZhSavO5KK-ZRmeAAAA
DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=pDZhSavO5KK-ZRmeAAAA
INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#pDZhSavO5KK-ZRmeAAAA with id 59035924
DEBUG [launcher]: PhantomJS (id 59035924) captured in 4.659 secs
DEBUG [phantomjs.launcher]:

DEBUG [middleware:karma]: custom files null null
DEBUG [middleware:karma]: Serving static request /context.html
DEBUG [web-server]: serving: /Users/application/node_modules/karma/static/context.html
DEBUG [web-server]: serving: /Users/application/node_modules/karma/static/context.js

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
You need to include some adapter that implements karma.start method!

@newdaveespionage
Copy link

Hey @aaron-zipnosis in your karma.conf.js, what does your frameworks entry look like? I'm curious if you're loading both karma-chai and karma-sinon-chai as they both load chai (I just use karma-sinon-chai since it has both.)

Also, if you gradually add items one at a time to the frameworks entry and re-run, is there a particular one that triggers this behavior?

@aaron-zipnosis
Copy link

aaron-zipnosis commented Aug 25, 2016

frameworks: ['mocha', 'sinon-chai']

I had no luck with adding frameworks gradually. I also added karma-chai-plugins and removed karma-chai, chai, sinon, karma-sinon-chai for simplicity in package.json

"devDependencies": {
    "karma": "^1.2.0",
    "karma-chai-plugins": "^0.7.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coffee-preprocessor": "^1.0.1",
    "karma-coverage": "^1.1.1",
    "karma-haml-attribute-concatenation-preprocessor": "^0.1.1",
    "karma-haml-preprocessor": "^0.1.0",
    "karma-mocha": "^1.1.1",
    "karma-ng-html2js-preprocessor": "^1.0.0",
    "karma-osx-reporter": "^0.2.1",
    "karma-phantomjs-launcher": "^1.0.1",
    "mocha": "^3.0.2"
  },

@newdaveespionage
Copy link

Hmm, have you tried cleaning out the npm_modules dir completely? I ask as I had a QA server stubbornly refuse to update even with the new version number until I wiped the directory completely.

The only other thing I can think of is possibly dropping the preprocessors and re-adding to see if anything bypasses that error, as there might be a use-case outside what this thread originally handled. Ultimately, if you're getting the karma.start error even with the frameworks array empty, then it's most likely karma not being current, or something outside my scope of knowledge (for instance, preprocessor handling is not something I delved into when working on my temporary local solution before 1.2.0 came out.)

@aaron-zipnosis
Copy link

I've consistently been rm -rf node_modules any time I update anything or add any other dependency just to be on the safe side. I've been caught by that a time or two.

@timmyLan
Copy link

var webpackConfig = require('../webpack.test');
module.exports = function(config) {
	config.set({
		// ... normal karma configuration
		files: [
			// all files ending in "_test"
			'test_index.js'
			// each file acts as entry point for the webpack configuration
		],

		preprocessors: {
			// add webpack as preprocessor
			'test_index.js': ['webpack']
		},

		browsers: ['Chrome'],

		webpack: webpackConfig,

		webpackMiddleware: {
			// webpack-dev-middleware configuration
			// i. e.
			stats: 'errors-only'
		},
		autoWatch: false,
		singleRun: false,
		port: 9876,
		colors: true,
		logLevel: config.LOG_INFO
	});
};

it work for me.when I remove autoWatch: falseoptions,this issues appear,I hop it can help you.

@ghost
Copy link

ghost commented Jun 6, 2017

This is a really bad error for missing a config file.

@rslifka
Copy link

rslifka commented Dec 3, 2017

Thanks to @megamindbrian for the TL;DR :) this is the error message you get after a fresh install if you have no Karma config file. Once you create a config file, the error goes away (even if you have no tests found). Happy testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment