-
-
Notifications
You must be signed in to change notification settings - Fork 3
Use Jest w/ Electron Runner so tests run & pass in a real browser #15
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
base: master
Are you sure you want to change the base?
Conversation
- use a full browser for testing instead of running in Node and relying on JSDOM, which does not implement all of the features we use (namely worker-related stuff) - this ensures tests run without any errors - and @jest-runner/electron is surprisingly **very fast**, not much different from running in normal jest w/ jsdom - like 4s locally fast I mean - refactor tests to Jest style from AVA style - remove all AVA-specifc config
- Node 8 Maintenance LTS is EOL in Jan 2020 - this also updates NPM to v6.9.0 (from v5.6.0) - could add some CI perf, esp w/ new usage of `npm ci` - but we run in under a minute anyway, so hard to beat that!
Noting here that I ran into some CI issues with Electron needing Also worthing noting is that Cypress doesn't seem to have this issue (it might wrap some |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this took a bit to trial-and-error and get running correctly (and coverage took far longer and too long to not work), the actual code changes are quite small, seems good to go!
- jest would just hang w/ no errors if xvfb wasn't configured - https://travis-ci.org/agilgur5/physijs-webpack/builds/617354543 - for more details see #15 (comment) - this fix is directly from the Electron CI instructions - https://github.com/electron/electron/blob/master/docs/tutorial/testing-on-headless-ci.md - not totally sure why it needs xvfb for headless, but it runs now
- per Travis CI's instructions - https://docs.travis-ci.com/user/gui-and-headless-browsers/#using-the-xvfb-run-wrapper - also apt addons doesn't seem to be needed - speeds up CI a bit too bc no apt-get update
- saw this on some blog posts, but caching on CI isn't directly documented in Electron for some reason - caching is mentioned in the installation docs though - https://github.com/electron/electron/blob/master/docs/tutorial/installation.md#cache
afe8187
to
03483a8
Compare
Jotting down here that https://github.com/facebook-atom/jest-electron-runner has been unmaintained and archived, but a quick search did find an updated fork: https://github.com/kayahr/jest-electron-runner. Thanks for supporting it! |
use a full browser for testing instead of running in Node and relying on JSDOM, which does not implement all of the features we use (namely worker-related stuff)
@jest-runner/electron
is surprisingly very fast, not much different from running in normal jest w/ jsdomalso update CI to work with electron and use Node 10 Active LTS
Fixes #7, Fixes #14
Unfortunately still having coverage problems as in #6 , so that hasn't changed between regular Jest and Jest w/ Electron runner, despite the bugs it should have fixed.
After having used Jest for a longer time period in some other projects, I've also come to prefer it to other test runners like AVA. I didn't like all the built-ins / stuff it does for you initially, but it's a lot less boilerplate and tends to be more intuitive. The runner output is also fantastic imo. Happy to change to it!