- Stably Cloud: Run tests on Stably’s infrastructure via the REST API with high parallelism and AI-powered features
- Self-Hosted Runners: Run tests on your own GitLab runners using the Stably SDK
playwright.config.ts configuration and Playwright projects.
Running on Stably Cloud (Recommended)
Run your tests on Stably’s cloud infrastructure for maximum scalability and AI-powered features. Since GitLab doesn’t have a native Stably action, you trigger cloud runs via the REST API.Prerequisites
- Playwright tests published to Stably Cloud from the Web UI
- Stably API key from settings page
- GitLab repository with CI/CD enabled
Setup
1
Configure GitLab Variables
Add your credentials as GitLab CI/CD variables:
- Go to
Settings > CI/CD > Variables - Add
STABLY_API_KEYwith your API key (mark as protected and masked) - Add
STABLY_PROJECT_IDwith your project ID (mark as masked)
2
Create Pipeline Configuration
Create or update
.gitlab-ci.yml:.gitlab-ci.yml
Running Specific Projects
Organize your tests using Playwright projects and run them selectively by passingprojects and grep in the API request body:
.gitlab-ci.yml
API Reference
View complete API documentation with all available endpoints, request/response schemas, and parameters
Running on Self-Hosted GitLab Runners
Run tests on your own GitLab runners using the Stably SDK for local execution with Stably’s AI features.Prerequisites
- A GitLab repository with
.gitlab-ci.yml - Node.js 20+ configured in your pipeline
- Playwright tests in your repository
Quick Setup
1. Install Stably Playwright SDK
Update your project dependencies to use Stably’s Playwright SDK alongside Playwright:package.json and lock file to your repository.
2. Update Test Imports
Replace all imports from@playwright/test with @stablyai/playwright-test in your test files:
3. Configure GitLab CI/CD Variables
Add your Stably API key as a GitLab CI/CD variable:- Get your Team API Key from Stably Settings
- Go to your repository at
Settings > CI/CD > Variables - Add a variable named
STABLY_API_KEYwith your API key - Mark it as “Masked” to protect the secret
4. Update Your GitLab CI/CD Configuration
Update your pipeline to use the Stably CLI:.gitlab-ci.yml
Using
npx stably test automatically injects the Stably reporter for enhanced analytics. You can also use npx playwright test directly if preferred..gitlab-ci.yml
Running Tests in Parallel (Self-Hosted)
When using self-hosted runners, leverage GitLab’s parallel keyword to distribute tests:.gitlab-ci.yml
For maximum parallelism (hundreds and thousands of parallel tests), use Stably Cloud instead of self-hosted runners.
Add Stably Reporter (Optional, but highly recommended)
To integrate with Stably’s cloud platform and view test results in the dashboard, configure the reporter in yourplaywright.config.ts:
playwright.config.ts
- Find your Project ID in your project settings on the Stably Dashboard and add it to your GitLab CI/CD variables at
Settings > CI/CD > Variables.
- Test execution timeline showing parallel run progress
- Screenshots and videos for failed tests
- AI-generated failure analysis and suggested fixes
- Historical trends and flakiness detection
- Detailed logs from each parallel job
Complete Pipeline Examples
- Basic Setup
- Parallel with Artifacts
- Multiple Browsers
- Matrix Jobs
- With Stably Reporter
Minimal configuration for single-threaded execution:
.gitlab-ci.yml
Pipeline-Specific Configuration
Cache Dependencies
Speed up your pipeline by caching node_modules:Run Only on Specific Branches
Limit test execution to specific branches or merge requests:Custom Docker Image
Use a custom Docker image with specific Playwright version:Troubleshooting
Missing Playwright Browsers
If you see errors about missing browsers, ensure you’re using the Playwright Docker image or install browsers explicitly:Timeout Issues
For long-running test suites, increase the job timeout:Permission Errors
If you encounter permission errors with the cache or artifacts, add:Next Steps
- Explore AI assertions for intelligent test validation
- Set up Slack notifications for test results
- Configure GitLab CI for pipeline status and reporting