Spectron is a great tool for testing your Electron applications. However, some help is needed to get the full use out of it. This post will go through all of the npm packages I’ve found useful in my Spectron testing.
Jasmine Reporters
The default reporter for Spectron is to just log out to the terminal. That’s great, but I like pretty colors in my terminal, especially when they’re green for success and red for error. That’s where the jasmine reporters package comes in. Actually, there are a few reporters in this package. Not just one for the terminal. In fact, I use two reporters from this package – the terminal reporter and the JUnit XML Result reporter.
Why do I use the second reporter? Well, that reporter plays very well with the jasmine-xml2html-converter package. This package converts the XML results from the JUnit XML Result reporter into an HTML file with graphs and a much easier way to view the tests.
Gulp
Yep, the package to have build tasks in your JavaScript projects has been useful for running Spectron tests. Whether you’re using Jasmine, Mocha, or Karma for your tests, there are gulp versions.
Something I’ve used that seemed to help is to break up your gulp tasks to run tests by scenario. For example, you can have a gulp task that just does log in tests, and another that just does customer profile tests. Gulp allows you to do dependencies as well, so you can have an e2e-all
task that runs everything and it can have all of the other tasks as dependencies to that task.
Spectron CLI Tool
Sure, a little plug on my newly released package, but I really feel like this can become a very useful tool for Spectron testing. Currently, it just creates files with a template, which I hope saves a lot of time to those who use it. I hope it can be as useful as the angular-cli is to Angular2 development.
This is just a few packages that have helped me out in my Spectron testing. As I gain more experience with it, this list will grow. As it does, I’ll make sure to keep this post updated.
Do you have any packages that you always use to help during your testing?