question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues in creating a new karma plugin.

See original GitHub issue

Hi I’m trying to create an karma plugin. Looks like I’m missing something down the line.

My package.json is

{
  "name": "testing",
  "version": "0.0.1",
  "description": "Test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "grooscript",
    "karma-grooscript"
  ],
  "devDependencies": {
    "karma": "^0.12.36",
    "grooscript" : "1.1.1"
  }
}

and my index.js is:

var path = require('path');

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

var framework = function(files) {
    files.unshift(pattern(path.join(__dirname, 'adapter.js')));
    files.unshift(pattern(path.resolve(require.resolve('grooscript'), '../grooscript.js')));
};

framework.$inject = ['config.files'];
module.exports = {'framework:testing': ['factory', framework]};

and my adapter.js is:

var gs;
(function(window) {
    window.gs = window.gs;
})(window);

All these files reside in a parent directory something like this:

testing/
    index.js
    adapter.js
    package.json

And in order to test them, I created an sample karma project. I installed the above plugin in the sample karma project like this:

npm link ../testing

which does install it (could able to see under the node_module directory). Then in the karma config.js, I added testing as frameworks:

module.exports = function(config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: '',

    frameworks: ['jasmine', 'dojo',"testing"] // <--- here

Once done, if I run the karma like:

karma start

I get an error like this:

/Users/user/programs/groovy/grooscript/esri-karma-tutorial/node_modules/karma/node_modules/di/lib/injector.js:9
      throw error('No provider for "' + name + '"!');
            ^
Error: No provider for "framework:testing"! (Resolving: framework:testing)
    at error (/Users/user/programs/groovy/grooscript/esri-karma-tutorial/node_modules/karma/node_modules/di/lib/injector.js:22:68)
    at Object.parent.get (/Users/user/programs/groovy/grooscript/esri-karma-tutorial/node_modules/karma/node_modules/di/lib/injector.js:9:13)
    at get (/Users/user/programs/groovy/grooscript/esri-karma-tutorial/node_modules/karma/node_modules/di/lib/injector.js:54:19)

where I’m making mistake?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dignifiedquirecommented, Jun 9, 2015

I’m supsecting your code gets executed in the test iframe rather than the outside frame (which is where the default karma window console drops you in) so if you want to debug from that frame you can use the iframe context switcher in the devtools to drop into the iframe and there window.hs should be defined

0reactions
devoto13commented, Apr 11, 2021

Closing as answered.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Karma test runner
Issues with coverage are probably related to your config, the compiler for coverage instrumentation, or possibly karma-coverage.
Read more >
karma plugin issue - IDEs Support (IntelliJ Platform) | JetBrains
Run any karma test that has a failing test - it will be marked as a failure. Correct the test, save the file,...
Read more >
any guide for writing karma plugins? · Issue #1254 - GitHub
HI, I had use framework plugin to compile and update files for karma. but still left one problem, while auto watch, karma can't...
Read more >
karma plugin dependencies not being found - Stack Overflow
The typical solution to the 'Perhaps you are missing some plugin?' message is to make sure it's included within the plugins array in...
Read more >
Upgrade karma-webpack to fix "DeprecationWarning: Tapable ...
When running Karma after the Webpack 4 upgrade ... Issue actions. New ... (node:27496) DeprecationWarning: Tapable.plugin is deprecated.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found