Skip to content

Get babel.dev.js working with Mocha #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
phzbox opened this issue Aug 4, 2016 · 4 comments
Closed

Get babel.dev.js working with Mocha #359

phzbox opened this issue Aug 4, 2016 · 4 comments

Comments

@phzbox
Copy link

phzbox commented Aug 4, 2016

Hi, I'm used to having a .babelrc and start mocha with: mocha --compilers js:babel-core/register, but I would like to reuse the .babel.dev.js in config/. Any hint in the right direction would be appreciated, thanks!

@gaearon
Copy link
Contributor

gaearon commented Aug 4, 2016

You can probably do something like

./mochaHook.js

var babelConfig = require('react-scripts/config/babel.dev');
require("babel-register")(babelConfig)

and then try mocha --compilers js:./mochaHook.

I’m not sure it would work but worth giving a try.

Note: this is not officially supported now. We may move or change react-scripts/config/babel.dev without warning in any version.

@phzbox
Copy link
Author

phzbox commented Aug 4, 2016

Perfect, it works. Thanks

@phzbox phzbox closed this as completed Aug 4, 2016
@joejknowles
Copy link

This has now been extracted to a babel preset: "babel-preset-react-app", in case anybody else finds their way here.

https://www.npmjs.com/package/babel-preset-react-app

https://github.com/facebookincubator/create-react-app/tree/master/packages/babel-preset-react-app

@gaearon
Copy link
Contributor

gaearon commented Jul 16, 2017

Also, to be clear, we've since added a built-in testing solution so you shouldn't need to run Mocha—unless you really want it over Jest for one or another reason.

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants