Babel 6 and Mocha

Tejas Manohar
1 min readDec 13, 2015

Babel 6 was released about 1.5 months back and though there are still some considerable issues and the documentation is sparse, it looks like it’s catching a lot of attention.

babel-core’s download stats on NPM

That said, I spent a fair bit of time figuring out how to use Mocha with Babel so thought I’d share what I came across with the rest of the community.

mocha --require babel-core/register

Remember, Babel has been split up into multiple packages in a giant monorepo and the core compiler itself is now in babel-core so you’ll need that installed as a dependency for this to work.

UPDATE: If you need async functions and other features that require a regenerator, include babel-polyfill as well. Thanks, @simplyianm!

--

--