TESTING.md
This guide explains how to run tests for the Screenshot to Code project.
The backend uses pytest for testing. All tests are located in the backend/tests directory.
Make sure you have Poetry installed and have installed all dependencies:
cd backend
poetry install
cd backend
poetry run pytest
poetry run pytest -vv
poetry run pytest tests/test_screenshot.py
poetry run pytest tests/test_screenshot.py::TestNormalizeUrl
poetry run pytest tests/test_screenshot.py::TestNormalizeUrl::test_url_without_protocol
poetry run pytest --cov=routes
poetry install --with dev pytest-xdist # Install if not already installed
poetry run pytest -n auto
The pytest configuration is defined in backend/pytest.ini:
tests directorytest_*.pyTesttest_backend/tests/ following the naming convention test_<module>.pyExample:
import pytest
from routes.screenshot import normalize_url
def test_url_normalization():
assert normalize_url("example.com") == "https://example.com"