Testing standards and style guidelines

This document describes various guidelines and best practices for automated testing of the GitLab project.

It is meant to be an extension of the Thoughtbot testing style guide. If this guide defines a rule that contradicts the Thoughtbot guide, this guide takes precedence. Some guidelines may be repeated verbatim to stress their importance.

Overview

GitLab is built on top of Ruby on Rails, and we're using RSpec for all the backend tests, with Capybara for end-to-end integration testing. On the frontend side, we're using Jest for JavaScript unit and integration testing.

Following are two great articles that everyone should read to understand what automated testing means, and what are its principles:

Testing levels

Learn about the different testing levels, and how to decide at what level your changes should be tested.

Testing best practices

Everything you should know about how to write good tests: Test Design, RSpec, FactoryBot, system tests, parameterized tests etc.

Frontend testing standards and style guidelines

Everything you should know about how to write good Frontend tests: Jest, testing promises, stubbing etc.

Getting started with Feature tests

Need to get started with feature tests? Here are some general guidelines, tips and tricks to get the most out of white-box testing.

Flaky tests

What are flaky tests, the different kind of flaky tests we encountered, and what we do about them.

GitLab pipelines

How GitLab test suite is run in the CI context: setup, caches, artifacts, parallelization, monitoring.

Review apps

How review apps are set up for GitLab CE/EE and how to use them.

Testing Rake tasks

Everything you should know about how to test Rake tasks.

End-to-end tests

Everything you should know about how to run end-to-end tests using GitLab QA testing framework.

Migrations tests

Everything you should know about how to test migrations.

Contract tests

Introduction to contract testing, how to run the tests, and how to write them.

Return to Development documentation