Testing Overview
n8n employs a comprehensive testing strategy with multiple layers:- Unit Tests: Jest for backend and nodes, Vitest for frontend
- Integration Tests: Jest with mocked dependencies
- E2E Tests: Playwright for full UI and API testing
- Workflow Tests: JSON-based integration tests for nodes
Running Tests
All Tests
Run all tests across the monorepo:Package-Specific Tests
Run tests for a specific package:1
Navigate to the package
2
Run the tests
Specific Test Files
Run a specific test file:Unit Testing with Jest
Backend Unit Tests
n8n uses Jest for backend unit tests with the following conventions:Frontend Unit Tests
Frontend tests use Vitest:Snapshot Updates
If tests fail due to expected changes, update snapshots:u in Jest watch mode.
Code Coverage
n8n tracks code coverage on Codecov.Local Coverage
Generate coverage reports locally:coverage/ folder or use the VSCode Coverage Gutters extension.
E2E Testing with Playwright
n8n uses Playwright for comprehensive E2E testing.Running E2E Tests
Test Architecture
Playwright tests follow a layered architecture:Page Object Pattern
Page objects encapsulate UI interactions:Composables
Composables orchestrate multi-step business workflows:Writing E2E Tests
Test Tags
Use tags to control test execution:Test Isolation
For tests requiring isolated databases:Tests with
@db:reset only run in container mode, not locally.Node Workflow Tests
Nodes include JSON-based workflow tests:Mocking Dependencies
Server Mocking with nock
Backend tests usenock for HTTP mocking:
Playwright Proxy Server
E2E tests can use proxy server for API mocking:Testing Best Practices
Mock all external dependencies in unit tests. Never make real HTTP requests or database calls.
Confirm test cases with the team before writing complex unit tests for new features.
Always run typecheck before committing:
Debugging Tests
Playwright Debugging
Jest Debugging
CI/CD Testing
Tests run automatically on CI:Test Maintenance
Thejanitor tool helps maintain test quality:
packages/testing/playwright/README.md for more details.
Next Steps
- Review contribution guidelines
- Learn about development setup
- Explore architecture overview