karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.96k stars 1.71k forks source link

No provider from "framework:browserify" #2466

Closed Elhebert closed 7 years ago

Elhebert commented 7 years ago

I'm trying to use karma to run my tests, and encounter some strange error.

I'm running everything locally, and don't have karma installed globally.

As you can see in the debug logs, all the plugins are loaded correctly. I have made some research here and on SO before posting, and tried every solution I found, but (obviously) none worked:

But still got the same issue. However, the issue varies sometimes:

If I add plugins: ['karma-browserify'] to my config file, it return me

No provider for "framework:mocha"!

But when I add plugins: ['karma-browserify', 'karma-mocha'], it return me

No provider for "framework:browersify"!

which is pretty weird.

So I'm open to suggestions :)

Actual behaviour

$ ./node_modules/karma/bin/karma start karma.conf.js 
22 11 2016 11:29:52.391:DEBUG [plugin]: Loading karma-* from /Users/elhebert/workspace/sites/api/node_modules
22 11 2016 11:29:52.396:DEBUG [plugin]: Loading plugin /Users/elhebert/workspace/sites/api/node_modules/karma-babel-preprocessor.
22 11 2016 11:29:52.715:DEBUG [plugin]: Loading plugin /Users/elhebert/workspace/sites/api/node_modules/karma-browserify.
22 11 2016 11:29:52.873:DEBUG [plugin]: Loading plugin /Users/elhebert/workspace/sites/api/node_modules/karma-chrome-launcher.
22 11 2016 11:29:52.879:DEBUG [plugin]: Loading plugin /Users/elhebert/workspace/sites/api/node_modules/karma-firefox-launcher.
22 11 2016 11:29:52.880:DEBUG [plugin]: Loading plugin /Users/elhebert/workspace/sites/api/node_modules/karma-mocha.
22 11 2016 11:29:52.882:DEBUG [plugin]: Loading plugin /Users/elhebert/workspace/sites/api/node_modules/karma-safari-launcher.
/Users/elhebert/workspace/sites/api/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
      ^

Error: No provider for "framework:browersify"! (Resolving: framework:browersify)
    at error (/Users/elhebert/workspace/sites/api/node_modules/di/lib/injector.js:22:12)
    at Object.parent.get (/Users/elhebert/workspace/sites/api/node_modules/di/lib/injector.js:9:13)
    at get (/Users/elhebert/workspace/sites/api/node_modules/di/lib/injector.js:54:19)
    at /Users/elhebert/workspace/sites/api/node_modules/karma/lib/server.js:143:20
    at Array.forEach (native)
    at Server._start (/Users/elhebert/workspace/sites/api/node_modules/karma/lib/server.js:142:21)
    at invoke (/Users/elhebert/workspace/sites/api/node_modules/di/lib/injector.js:75:15)
    at Server.start (/Users/elhebert/workspace/sites/api/node_modules/karma/lib/server.js:103:18)
    at Object.exports.run (/Users/elhebert/workspace/sites/api/node_modules/karma/lib/cli.js:280:26)
    at Object.<anonymous> (/Users/elhebert/workspace/sites/api/node_modules/karma/bin/karma:3:23)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
error Command failed with exit code 1.

Environment Details

browserify: { debug: true, transform: [ ['babelify', { plugin: ["babel-plugin-es2015"] }] ], extension: ['.js'] },

- packages.json:
```json
"devDependencies": {
    "babel-cli": "^6.18.0",
    "babel-core": "^6.18.2",
    "babel-preset-es2015": "^6.18.0",
    "babelify": "^7.3.0",
    "browserify": "^13.1.1",
    "karma": "^1.3.0",
    "karma-babel-preprocessor": "^6.0.1",
    "karma-browserify": "^5.1.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-firefox-launcher": "^1.0.0",
    "karma-mocha": "^1.3.0",
    "karma-safari-launcher": "^1.0.0",
    "mocha": "^3.1.2",
    "watchify": "^3.7.0"
},
vivganes commented 7 years ago

@Elhebert It seems like you need to use karma-browserify in the plugins property.

Your plugins section needs to look like this:

plugins: [
  'karma-browserify'
],

Did you come across the solution mentioned in this comment : https://github.com/nikku/karma-browserify/issues/96#issuecomment-73027261

In case your plugins section already has some other entries, just add karma-browserify to the plugins array along with existing items.

Please let me know how this goes

Elhebert commented 7 years ago

@vivganes Thanks for your reply but as I explained I already tried that. Didn't worked.

I'm still trying to figure it out, but so far, haven't found any solution.

vivganes commented 7 years ago

@Elhebert Is it possible for you to post the full karma.config.js (after masking any sensitive information)?

This will help in understanding some more about your situation

Elhebert commented 7 years ago

@vivganes Sure, not a problem:

// Karma configuration
// Generated on Tue Nov 22 2016 10:00:32 GMT+0100 (CET)

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

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

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

    browserify: {
      debug: true,
      transform: [
        ['babelify', { plugin: ["babel-plugin-es2015"] }]
      ],
      extension: ['.js']
    },

    // list of files / patterns to load in the browser
    files: [
      'src/**/**.spec.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: {
      'src/**/**.spec.js': ['browserify']
    },

    // 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_DEBUG,

    // 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', 'Safari', 'Firefox'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

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

As I stated before, I tried to add the plugins array with karma-browserify, but it didn't help.

maksimr commented 7 years ago

@Elhebert you have a typo in word 'browserify'.

X - browersify
V - browserify

Elhebert commented 7 years ago

@maksimr OMG, I'm going to hang myself...

Thanks !

vivganes commented 7 years ago

@Elhebert me too...