-
Notifications
You must be signed in to change notification settings - Fork 63
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
[Feature request] Integrate with mocha-webpack #102
Comments
Is this still something that's a possibility? There are only a few issues left open here including this one so figured it might still be somewhat on the roadmap. The project we're working on uses We'd be willing to help get this off the ground - unit testing stuff in Electron has proven a bit elusive for us and we'd like to have a good solution out there for anyone else who runs into this. |
This project tries, as much as possible, to be a drop-in replacement for Mocha in Electron. The only extra features it adds are to expose specific characteristics of the Electron environment (main vs renderer process, debugging, the timing of when files are loaded etc.). Adding support for webpack is out of scope for this project. That said, obviously we can try to make it easier to integrate webpack in the testing process. I don't know about the mocha-webpack project mentioned in the OP, but if this is a 'wrapper' around mocha, for example, we might be able to help make it possible to wrap electron-mocha in a similar way. I've seen electron-mocha used for testing Electron apps in a wide variety of setups (with or without pre-compilers, code coverage instrumentation) and have found it to be quite flexible. If you elaborate on specific issues at hand, it might be easier to make a call on whether they can be solved by electron-mocha itself or whether they should be addressed outside of it. |
The
It basically just simplifies all the More specifically, we are using Vue, whose test utility relies on If you clone that repo and run
you will see that it errors out with a dummy test that utilizes It's very possible I'm attempting to use
There's probably a good way to do this, but I'm not smart enough to know it. I'm OK with running e2e tests separately using Would it be possible to add a flag like |
electron-mocha starts an Electron main process and then either runs mocha directly in that process, or, if you run with the Your example runs in the main process and When you're unit testing an Electron app you're testing code that runs either in the main processes or in a renderer (or both); typically, you'll run electron-mocha twice, once in each mode. (Your test in the main process can also spawn their own windows of course, and you could roll your own e2e tests like that, but electron-mocha does not provide any helpers for that). electron-mocha does not simply call the mocha binary; instead it does very much the same thing the mocha binary does, but in an electron environment (plus handling some additional switches). It seems to me that what mochapack provides (or watching for changes and similar tasks in general) is something that should happen outside of electron-mocha. electron-mocha just runs the tests in either of the two Electron processes. |
@inukshuk Thanks for the quick responses, just trying to zero in on a good resolution here and I appreciate all the help.
If I'm tracking correctly, this would just boil down to running
I agree that This is my first foray into really setting up a testing environment with |
Yes this sounds reasonable. In my experience it's very common to run electron-mocha twice; if your code is separated into a Since renderer tests run in their own browser window, there's a relatively large overhead if you start electron-mocha for each file change separately -- to make it more efficient you'd have to run the watch code in the same process. I'm guessing that this is what |
Any update on this? Trying to get Is it possible to pass to electron-mocha the mocha we want to use? In this case it would be mockapack. @Jack-Barry you suggested the "--mockapack". Any pointers on where I should look at? |
@rasgo-cc I did not get around to implementing the BYOM (Bring Your Own Mocha) feature in
|
I would like to use this library to test Angular applications on Electron built with Webpack.
I think the best way to do this is to add a command-line option to launch mocha-webpack instead of Mocha.
There are two distinct builds which should be enabled and disabled independently:
For the renderer, Webpack test code will be loaded by HTTP from the Webpack DevServer rather than required.
The text was updated successfully, but these errors were encountered: