2

I'm trying to get my karma jasmine unit testing back up running after introducing a bunch of commonJS (at least I guess that's what it's called) and starting to use package.json and upgrading all packages and get errors everywhere.

Running gulp test, I get

[04:01:55] Using gulpfile ~/workspace/thisapp/Gulpfile.js
[04:01:55] Starting 'test'...
[04:01:55] Starting Karma server...

/home/leo/workspace/thisapp/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
            ^
Error: No provider for "framework:browserify"! (Resolving: framework:browserify)
    at error (/home/leo/workspace/thisapp/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (/home/leo/workspace/thisapp/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (/home/leo/workspace/thisapp/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at /home/leo/workspace/thisapp/node_modules/karma/lib/server.js:29:14
    at Array.forEach (native)
    at start (/home/leo/workspace/thisapp/node_modules/karma/lib/server.js:28:21)
    at invoke (/home/leo/workspace/thisapp/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (/home/leo/workspace/thisapp/node_modules/karma/lib/server.js:307:12)
    at Object.<anonymous> (/home/leo/workspace/thisapp/node_modules/gulp-karma/lib/background.js:3:8)
    at Module._compile (module.js:456:26)

with

    frameworks : [ 'jasmine', 'browserify' ],

in my karma config and this (horribly) set of dependencies:

"browserify": "^10.2.3",
"browserify-shim": "^3.8.9",
"esmangle": "^1.0.1",
"gulp": "^3.9.0",
"gulp-browserify": "^0.5.1",
"gulp-cordova": "^0.1.2",
"gulp-if": "^1.2.5",
"gulp-jshint": "^1.11.0",
"gulp-karma": "0.0.4",
"gulp-replace": "^0.5.3",
"gulp-shell": "^0.4.2",
"gulp-sourcemaps": "^1.5.2",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.5",
"jasmine-core": "^2.3.4",
"karma": "^0.12.37",
"karma-browserify": "^4.2.1",
"karma-chrome-launcher": "^0.2.0",
"karma-commonjs": "0.0.13",
"karma-jasmine": "^0.3.6",
"karma-jasmine-html-reporter": "*",
"karma-phantomjs-launcher": "^0.2.0",
"phantomjs": "^1.9.17",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"

Now my assumption would be that if karma-jasmine works, which it does (browserify was the latest addition, as the tests need some requires and karma-commonjs results in the same issues as karma-browserify), then karma-browserify should work equally.

But, for a very similar error of karma-jasmine not being found I had switched from karma to gulp-karma, as there I found the error and it was marked as fixed, which at least for karma-jasmine it is.

In the end I need karma with require and gulp would be nice to have but I'm lost.

Giszmo
  • 1,944
  • 2
  • 20
  • 47

1 Answers1

1

You need to add it also to plugins of your karma config:

plugins : [
    'karma-junit-reporter',
    'karma-chrome-launcher',
    'karma-firefox-launcher',
    ....
    'karma-commonjs',
    'karma-browserify'
],
Markus
  • 1,069
  • 8
  • 26