Introducing Wallaby – Concurrent Feature Tests for Elixir and Phoenix

Posted on by in Elixir

Feature tests are one of the best ways to ensure reliability and consistency for web applications. But, as we’ve discussed previously feature tests can become a performance bottleneck for a large test suite.

With the fast approaching release of Ecto 2.0, Elixirists will be able to run feature tests for Phoenix applications concurrently. To take advantage of these performance benefits we wanted a testing tool that supported concurrent tests out of the box and provided a flexible api for querying and interacting with webpages.

Thats why we built Wallaby.

Introducing Wallaby

Wallaby is a concurrent, feature testing library for Elixir and Phoenix applications. It provides a flexible api for querying and selecting visible DOM elements and their attributes. For instance if you wanted to query a list of users you could write a test like this:

Concurrent by default

We’re big fans of PhantomJS for feature tests. Wallaby manages a pool of PhantomJS browsers to run each test case concurrently. This ensures that tests don’t share session information or cookies.

Interacting with forms

We like readable tests. Wallaby allows you to interact with form elements based on their id, name, or label text:

If actions need to be scoped within a specific DOM node then they can be composed with a finder:

Asynchronous pages

It can be difficult to test pages that load data asynchronously or rely on javascript rendering. You may try to interact with an element that isn’t visible on the page yet. Wallaby’s finders try to help mitigate this problem by blocking until the element becomes visible. You can use this strategy by writing tests in this way:

Simultaneous browsers

Because Wallaby supports running tests concurrently its possible to simulate multiple browsers in a single test:

We use this technique to test our applications that rely on Phoenix Channels for communication.

Get Started

For more examples and information on how to set up Wallaby in your application see the hex docs and the github repo.

Give it a try and let us know what you think.