Blog

Testing Electron Apps

Published on
January 13, 2022
Tessa McDaniel
Marketing Team Lead

What is Electron, and how can you test these desktop apps? Find out here!

One of the neat things about testing is that sometimes it’s a lot more versatile than meets the eye. For example, take Electron apps - these are a particular flavor of packaged apps. There are several different ways to go about testing those, but before we dive into that, let’s look at what Electron is.

What is Electron?

Electron is a platform designed by GitHub that builds cross-platform desktop apps with JavaScript, HTML, and CSS. Basically, you build your desktop app as a website, and then the platform renders each webpage into a window using Chromium and Node.js. This also means that the desktop and website versions have a native feel (feel like they were built specifically for that platform) and high compatibility. 

Lots of desktop apps use Electron like GitHub Desktop (naturally), Slack, Skype, Visual Studio Code, Discord, WhatsApp Desktop, and more! These apps all look the same no matter which operating system you use them on, and that is one of the reasons companies will choose to use Electron. Plus, the framework is easy to use, so Electron is doubly attractive. On the user side, Electron apps are handy because we know that we can type emojis like 😂 as :joy: in Slack, WhatsApp, and Discord messages, so we don’t have to relearn how to enter emojis for each system.

Spectron Testing

Electron even has its own built-in testing! It’s called Spectron, and it uses ChromeDriver and WebDriverIO to dive into the apps’ APIs. It’s also compatible with testing libraries like Jasmine, Mocha, and Chai (anyone else want tea now?). The tests are written like JavaScript integration tests, and there are ways to avoid duplicating code that you’ve written. Continuous integration is a bit more complicated because it requires a display driver that has to be installed, and it also depends on what CI is being used. For example, Jenkins CI users have to install a plugin to get a display driver, but CircleCI users already have the display driver set up by default. 

Testing Electron with Virtuoso

Ok, now we can loop back to testing software versatility. Because of the extra configurations required for Electron apps, Spectron perhaps isn’t the perfect tool for everyone’s unique situation. Even though Electron apps are desktop applications, Virtuoso can still test them because Electron apps are put together as a website. Other testing software that can test Electron apps often aren’t no-code or can’t handle testing multiple windows open at once.

Because you don’t need to build a different app for each environment with Electron, you can save a pretty chunk of change. The same goes for testing with Virtuoso: write one test and run it over all your environments! Added bonus, no installation or setup is required since it’s all done over the cloud. So, if you’re building an Electron app, why wouldn’t you want to make the testing as easy as possible on yourself? Check out Virtuoso so you can unlock speed and scale by testing your Electron apps with a no-code solution that just works.

Subscribe to our Newsletter