Skip to content

Testing Guide

This guide covers running and writing tests for the Open Library project.

Running Tests

Run All Tests

bash
docker compose run --rm home make test

Run Python Tests Only

bash
docker compose run --rm home pytest

Run a specific test file:

bash
docker compose run --rm home pytest openlibrary/plugins/importapi/tests/test_import_validator.py

Run tests matching a pattern:

bash
docker compose run --rm home pytest -k "test_name_pattern"

Run JavaScript Tests

bash
docker compose run --rm home npm run test

Run Type Checks

bash
docker compose run --rm home make mypy

Linting

Open Library uses automated linting to maintain code quality and consistency. The CI server automatically checks all pull requests for linting issues. To save time, you can run these checks locally before pushing your changes.

Quick Reference

TaskCommand
Run all lintersdocker compose run --rm home make lint
Lint JavaScriptdocker compose run --rm home npm run lint
Lint Pythondocker compose run --rm home make lint
Run pre-commit hookspre-commit run --all-files
Bypass pre-commitgit commit --no-verify

For details on setting up and troubleshooting pre-commit, see the Pre-Commit Guide.