Gasim Gasim - 27 days ago 18
React JSX Question

Karma gives me a __karma__.start adapter error without any other error

I don't know how to fix this issue. I get no errors other than the one above. Here are my config files:

./webpack.config.js

var path = require('path');
var webpack = require('webpack');

module.exports = {
entry: './src/app/app.jsx',
output: { path: __dirname, filename: 'app.js' },
port: 9090,
devServer: {
contentBase: './src',
hot: true,
port: 9090,
publicPath: '/assets/',
noInfo: false
},
resolve: ['.js', '.jsx', ''],
module: {
loaders: [
{
test: /.jsx$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}
]
},
};


./karma.conf.js

var webpackConfig = require('./webpack.config');
webpackConfig.devtool = 'inline-source-map';

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

frameworks: ['mocha', 'chai', 'sinon', 'sinon-chai'],
plugins: [
'karma-chrome-launcher',
'karma-mocha',
'karma-chai',
'karma-sinon',
'karma-sinon-chai',
'karma-sourcemap-loader',
'karma-webpack'
],
files: [
'tests.webpack.js'
],
exclude: [],
preprocessors: {
'tests.webpack.js': ['webpack', 'sourcemap']
},

webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},

reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['Chrome'],
singleRun: true,
});
}


./tests.webpack.js

'use strict';

require('babel-polyfill');
require('core-js/fn/object/assign');

var context = require.context('./test', true, /Test\.jsx$/);
context.keys().forEach(context);


An example test file (test/app/AppTest.jsx):

'use strict';

var TestUtils = require('react-addons-test-utils');
import {expect} from 'chai';

describe('App', () => {

it('should display correct text on render', () => {
let component = TestUtils.renderIntoDocument(<App/>);
expect('hello').to.equal('hello');
});

});


Here is karma debug output (I removed the times, so it was more readable):

DEBUG: [config]: autoWatch set to false, because of singleRun
DEBUG [plugin]: Loading plugin karma-chrome-launcher.
DEBUG [plugin]: Loading plugin karma-mocha.
DEBUG [plugin]: Loading plugin karma-chai.
DEBUG [plugin]: Loading plugin karma-sinon.
DEBUG [plugin]: Loading plugin karma-sinon-chai.
DEBUG [plugin]: Loading plugin karma-sourcemap-loader.
DEBUG [plugin]: Loading plugin karma-webpack.
DEBUG [web-server]: Instantiating middleware
DEBUG [preprocessor.sourcemap]: base64-encoded source map for /Users/gasim/Stack/gasim/gasim-frontend/tests.webpack.js
INFO [karma]: Karma v1.1.0 server started at http://localhost:9876/
INFO [launcher]: Launching browser Chrome with unlimited concurrency
INFO [launcher]: Starting browser Chrome
DEBUG [temp-dir]: Creating temp dir at /var/folders/0q/z4cbhb7x49jgk2ycw4f9hxd00000gn/T/karma-37005516
DEBUG [launcher]: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/var/folders/0q/z4cbhb7x49jgk2ycw4f9hxd00000gn/T/karma-37005516 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling http://localhost:9876/?id=37005516
DEBUG [web-server]: serving: /Users/gasim/Stack/gasim/gasim-frontend/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /Users/gasim/Stack/gasim/gasim-frontend/node_modules/karma/static/karma.js
DEBUG [karma]: A browser has connected on socket /#ZLT5diBbmtOJweMIAAAA
DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=ZLT5diBbmtOJweMIAAAA
DEBUG [web-server]: serving: /Users/gasim/Stack/gasim/gasim-frontend/node_modules/karma/static/favicon.ico
INFO [Chrome 51.0.2704 (Mac OS X 10.11.5)]: Connected on socket /#ZLT5diBbmtOJweMIAAAA with id 37005516
DEBUG [launcher]: Chrome (id 37005516) captured in 2.52 secs
DEBUG [middleware:karma]: custom files null null
DEBUG [middleware:karma]: Serving static request /context.html
DEBUG [web-server]: serving: /Users/gasim/Stack/gasim/gasim-frontend/node_modules/karma/static/context.html
DEBUG [web-server]: serving: /Users/gasim/Stack/gasim/gasim-frontend/node_modules/karma/static/context.js
Chrome 51.0.2704 (Mac OS X 10.11.5) ERROR
You need to include some adapter that implements __karma__.start method!


What really interests me is the following line in the debug output:

DEBUG [middleware:karma]: custom files null null


Why does it say
null null
? Does this mean files for tests are empty or something?

Answer

The problem here in this line here:

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

There is no need to include chai or sinon. They were the ones giving me errors. So, I only kept mocha and sinon-chai and I just load chai and sinon from within my test scripts.

Comments