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.

Correct inline plugin example?

See original GitHub issue

On the Plugins page of the documentation, the following example is presented:

plugins: [
  // Karma will require() these plugins
  'karma-jasmine',
  'karma-chrome-launcher'

  // inlined plugins
  {'framework:xyz', ['factory', factoryFn]},
  require('./plugin-required-from-config')
]

Although I haven’t needed to write my own inline plugins yet, I doubt the example provided is correct, since it’s not even valid JavaScript syntax. Should it be { 'framework:xyz' : [ 'factory', factoryFn ] } instead? A little explanation on that point would be appreciated.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
rvowlescommented, Mar 11, 2015

I don’t know if this is useful, but it is my local karma override file with a custom plugin that runs my delcom build light.


var exec = require('child_process').exec;

var DelcomReporter = function(helper, logger) {
    console.log('i am a delcom reporter');
    var log = logger.create('reporter.delcom');

    function delcom(colour) {
        log.info('setting delcom to ', colour);
        exec('/usr/local/bin/delcom-stoplight ' + colour, function(error, stdout, stdin) {
        }).unref();
    }

    this.adapters = [];
    this.browserCount = 0;
    this.buildOk = false;
    this.onRunStart = function(browsers) {
        this.browserCount = browsers.length;
        this.buildOk = true;
        delcom('blue');
    };

    this.onBrowserComplete = function(browser) {
        var results = browser.lastResult;
        if (results.disconnected || results.error || results.failed) {
            this.buildOk = false;
        }
    };

    this.onRunComplete = function() {
        delcom(this.buildOk ? 'green' : 'red');
    };
};

DelcomReporter.$inject = ['helper', 'logger'];

config.set({
      //browsers: ['Chrome', 'Firefox', 'Safari']
      browsers: ['Chrome'],
    plugins: [
              // Karma will require() these plugins
              'karma-jasmine',
              'karma-chrome-launcher',
                'karma-ng-html2js-preprocessor',

              // inlined plugins
              {
                    'reporter:delcom': ['type', DelcomReporter]
                }
       ],
    reporters: ['progress', 'delcom']
    });
1reaction
zyf0330commented, Feb 4, 2021

I want to coment one thing. For framework inline plugin, factory function must not be arrow function, otherwise it gives error TypeError: Cannot read property '1' of null

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are inline plugins? - grails - Stack Overflow
The inline plugins can help you to debug an application or change the code of your plugins to do your tests, instead of...
Read more >
Writing a Plugin - webpack
Here each of the plugins is called one after the other with the arguments from the return value of the previous plugin. The...
Read more >
Inline editor example | Docs - TinyMCE
This example shows you the inline editing capabilities of TinyMCE. TinyMCE HTML CSS JS Edit on CodePen.io. The world's first rich text editor...
Read more >
Plugins | Chart.js
Using plugins​​ Copied! inline plugins are not registered. Some plugins require registering, i.e. can't be used inline. const chart = new Chart( ...
Read more >
Inline Style Plugin - Froala
Inline Style Plugin · Plugin options: · Plugin methods: · Add Plugin to your code: · Example :.
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