Skip to content
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

Support --compilers arg #16

Merged
merged 3 commits into from
Oct 16, 2015
Merged

Conversation

vidbina
Copy link
Contributor

@vidbina vidbina commented Oct 15, 2015

In order to support mocha compilers, the CLI --compilers argument has been pulled to the electron-mocha front-end, which makes calls like electron-mocha --compilers js:babel/register test/example.js possible in case one has written tests in ES6 for example.

@jprichardson
Copy link
Owner

Why not just use require? Also, ping @jg123 for his thoughts (re: #15)

@vidbina
Copy link
Contributor Author

vidbina commented Oct 16, 2015

Hey @jprichardson what do you mean with the require? I basically just mimicked mochajs/mocha/bin/_mocha. I noticed that a considerable part of the code in electron-mocha was about providing a custom implementation of mochajs/mocha/bin/_mocha so in the spirit of pragmatism I came up with the simplest way out. If not "sound", I'd be glad to receive proposals for a fix 😉

@jprichardson
Copy link
Owner

If you create a file, say babel.js that includes require('babel-core/register'), you could then call electron-mocha --require ./babel.js test-file.js.

But I imagine that a lot of people are going to expect the Mocha --compilers flag to work, so maybe I'll just accept this since it's not much code to maintain.

@vidbina
Copy link
Contributor Author

vidbina commented Oct 16, 2015

Ah. I haven't tried that approach before, but I guess both options will do. Personally I'd prefer the --compilers approach because it:

  • is the proposed implementation posted on babeljs.io/docs/setup#mocha for Mocha tests (which means many are familiar with it and offering a similar usage pattern makes life easier for most)
  • does not involve an additional file to be required which only contains some boilerplate. The --compile flag performs the require(mod) and appends to extensions. The one thing it doesn't do is set up watchers as Mocha does, but I guess for now we'll take that as a minor inconvenience.

@jg123
Copy link

jg123 commented Oct 16, 2015

I also prefer not having to create the extra file. What perfect timing!

jprichardson added a commit that referenced this pull request Oct 16, 2015
@jprichardson jprichardson merged commit e17c8ba into jprichardson:master Oct 16, 2015
@jprichardson
Copy link
Owner

Decided to merge because I anticipate demand will be high for this feature. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants