Search code examples
karma-runnerbabeljsecmascript-2016

How can I use ES2016 decorators in karma?


I have set up karma with the karma-babel-preprocessor, and es2015 in the presets.

I'm using decorators in my code but I don't know how to configure karma to accept them. I have been trying for a while unsuccesfully.

Adding plugins: ['transform-decorators'] to the babelPreprocessor options doesn't help.

Any help will be appreciated.


Solution

  • This was caused by a currently open issue regarding decorators (which I'm using) and babel.

    See these issues in Babel:

    #2645 - Fix Decorators

    #2801 - Failed to transform decorators with babel-plugin-transform-decorators@6.0.14

    #2727 - Decorators are broken in 6.x