karma-runner / karma

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

ES6 Arrow Functions Breaks Middleware Factory #2781

Open deckar01 opened 7 years ago

deckar01 commented 7 years ago

Expected behaviour

Karma should allow ES6 arrow functions for a middleware factory. It should behave the same as if a traditional function was passed.

Actual behaviour

Karma throws "Cannot read property '1' of null", because it is trying to reflect the functions parameters as a string and is assuming "function" will be present.

Environment Details

Karma version: 1.7.0

Relevant part of your karma.config.js file:

{
  beforeMiddleware: ['jinja'],
  plugins: [
      'karma-*',
      {'middleware:jinja': ['factory', () => renderJinjaTemplate]},
  ]
}

Steps to reproduce the behaviour

  1. Add a custom middleware plugin
  2. Add a factory plugin for the middleware
  3. Pass an arrow function as the middleware's factory
deckar01 commented 7 years ago

I tracked down the issue to the vojtajina/node-di dependency. Unfortunately that project has was depreciated in favor of a project that was unreleased and got abandoned in favor of coupling it to the angular core...

Would you be open to a fork of di?

mgechev commented 7 years ago

@deckar01 another alternative is migration to the DI implementation in @angular/core or its extraction at injection-js.