Hack Day: WebdriverIO and Mocha

June 23rd was the second hack day that has occurred since I joined Automattic in July 2014, and the first hack day that I participated in.

For this hack day, I chose to figure out something for functional testing since it’s 1) so far been a bit over my head and 2) could prove useful in my work at Automattic.

What is a hack day?

In the hack day announcement post, one of my coworkers described the hack day as:

The Hack Day is an opportunity to work on anything and everything around Automattic’s services and/or WordPress.

Personally, I looked at the hack day as an opportunity to learn a new technology that I’d been interested in but hadn’t had the chance to learn yet.

A new functional testing framework

A few weeks ago, I spent a full day trying to figure out why a functional test was no longer working on WordPress. Long story short, I was able to narrow down the issue to a conflict with PhantomJS and React, the latter of which now powers a large part of WordPress.com.

After figuring this out, I began to look into different testing frameworks that would allow us to test React, and eventually settled on WebdriverIO for the browser automation. This seemed to be a fairly easy choice because WebdriverIO:

  • supports multiple browsers (including Chrome which works with React)
  • is built with JavaScript
  • is able to be deployed on hosted testing services like SauceLabs or Browserstack
  • has a plugin for visual regression testing

The end result

While I’m not sure I can call what I ended up with a “framework”, I am happy with what I was able to do in just one day.

I was able to get tests written for logging in and out of WordPress.com as well as testing deactivation/activation plugins through Jetpack Manage functioned as expected.

You can find the source code at: https://github.com/ebinnion/WordPress.com-Functional-Tests

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.