Search code examples
jasminekarma-runnerbrowserifytraceurgulp-karma

ES6 - how to test Jasime tests thru karma using ES6 like 'import' statement


I am new to javascript, trying to write a spec having an ES6 like import statement and then execute it thru Karma with pre-processors as traceur and browserify (to bundle and provide 'require' method). It continues to give me an error of invalid syntax and on looking at the specs file rendered in browser it looks that traceur never really processed the file.

This is the link to project on github -> https://github.com/gt-tech/es6-traceur-browserify-karma

I have also described the issue here as I am using that generator -> https://github.com/Swiip/generator-gulp-angular/issues/380


Solution

  • Issue is solved though not sure if it's the best way to solve it. Since we were trying to use "traceur" and "browserify" in a chained pre-processing we figured that for some reasons, they aren't really getting executed in a chain. Both of these processed the files (matching the path) independently messing up the eventual output. We took traceur out of equation and utilized "es6ify" transform within browserify to achieve transpilation and it worked like a breeze.

    I am sure it's a beginner's question for many but hopefully it will help someone else taking their initial steps