Open gregglind opened 9 years ago
(working on a custom loader, based on the coffee script one at: https://gist.github.com/a6e636742a04274a9bf1 )
This would be great. I've done something similar to hack in JSX/Harmony support w/ blanket here.
:+1:
Any further work on this?
I'm currently trying to use blanket
like this:
mocha --compilers js:babel/register --require blanket
And naturally esprima
is exploding pretty quickly.
:+1: Same here.
mocha --compilers js:babel/register --require blanket test/*.js*
does not work.
+1
looks similar to the pull request I made to add multiple loader support and a CXJS loader: https://github.com/alex-seville/blanket/pull/523 after extracting some common functionality, new loaders become much easier: https://github.com/scruffles/blanket/blob/208230900d43d50c7a71b30d5f74445cfae7423a/src/node-loaders/cjsx.js
I'm having the same problem as @dcousens. React + ES6 just won't happen with blanket.
I've been through the mocha-react repo but I still can't figure this out.
currently there is no command line switch that will add support for a loader, but you can add support for a loader with 12 lines of code. Just copy and alter this file, and configure it like this:
"config": {
"blanket": {
"loader": "../../../test/cjsx-loader"
}
},
I haven't tried JSX, but it works fine with CJSX.
It seems like extending it further to support the command line syntax suggested above shouldn't take too much work. If someone does implement that, please send a pull request to Alex, so we can all benefit.
Would be sweet if you could just do this:
mocha --compilers js:babel/register --require blanket --reporter html-cov > coverage.html
Any feedback?
:+1: @kristoferjoseph
+1 This would amazingly useful.
I have a local implementation that preserves backwards compatibility. You still have to apply a loader in your config:
"config": {
"blanket": {
"loader": ["./node-loaders/dynamic-loader"]
After that, it just wraps all the existing mocha loaders and instruments those files that fit the filters. The coverage report still shows the transpiled javascript. I didn't mess with any of the fundamentals. Just introduced a new loader.
I could make it the default loader. Also, as far as I can tell the existing loader concept could go away completely. I didn't want to do any more work until I was sure I wasn't wasting my time. Should I submit a pull request as it is now and weed out the loader concept in a separate request? Is this the direction the project should go?
Goal
Transpiled code should be covered, either in original or transpiled forms. (SO THAT things like react-jsx, es6 will work)
implementation ideas
--compilers
option for blanket?Ref code
https://github.com/mochajs/mocha/blob/master/bin/_mocha#L292-L301