Overview

Ghost Inspector is a (mostly) no-code approach to automated frontend testing. It allows us to automatically regression test site features on a regular, frequent basis. It integrates well with Slack to notify of test results, and Gitlab as part of a CD/CI strategy.

Rules for Ghost Inspector

✅ Do…

🚫 Don’t…

Ideal Implementation

The ideal implementation for any site should meet this list. More can be done, but this is considered the minimum for a “complete” usage. Diverge from it only in exceptional cases.

Our Approach to Ghost Inspector

Designing Tests

For best results, a test should be concrete, as small as possible and have a defined answer: if we want to test a navigation menu, we don’t write one test to check everything on the menu. We write multiple tests to check “navigation menu expands on hover”, “search directs to appropriate search result URL”, “contact modal opens and closes”, and so on.

When writing tests, focus on making them modular and able to be used on multiple URLs. Don’t write a test hard-coded for cantilever.co - write a test of steps that we can later choose to use on cantilever.co (or a staging subdomain, or another temporary build URL, or on a local environment, etc).

Naming Conventions

Test Construction & Organization

Cantilever builds tests in Ghost Inspector as modules first: these tests are meant to be URL-agnostic and not ran on their own. When we want to run a test, we import the module into a new test and suite, and run that instead. This gives a few benefits:

  1. We only have to build the test once, then can run it at any number of URLs (production vs staging vs merge branch preview, etc).