Overview
A test execution environment is a sandboxed environment where Tusk runs the tests it generates. Think of it as a Docker container specifically configured for your project’s testing needs.Test execution environments are fully managed by Tusk. We handle:
- Infrastructure and resource allocation
- Initial configuration during automated setup
- Ongoing maintenance as your project evolves
How It Works
When Tusk generates tests for a PR, it:- Spins up an isolated sandbox using your test execution environment
- Checks out your code at the PR’s commit
- Runs setup scripts to install dependencies
- Uses test and lint scripts to ensure all generated tests are working and conforming to your codebase’s standards
- Reports results back to your PR
Setting Up Test Environments
Upon successful GitHub/GitLab authorization, navigate to the Unit Tests page and click Set up on the repo you want to configure.Analyze your repository
If you haven’t already, click Analyze Repository Tusk examines your codebase to identify directories containing unit tests, testing frameworks, CI/CD configuration, and potential environment variables needed.This typically takes 2-4 minutes.
Review detected test environments
After analysis, you’ll see a list of potential test environments. For each one, Tusk shows prerequisites:
- Directory path (for monorepos with multiple services)
- Test framework detected
- CI status - whether tests currently run in CI
- Coverage support - whether Tusk can collect coverage data
Provide environment variables (if detected)
If Tusk detects that environment variables may be required (like NPM tokens for private packages), you’ll be prompted before setup begins.You can:
- Provide values now to ensure setup succeeds on the first try
- Skip for now (Tusk will attempt setup without them and ask again if needed)
Wait for configuration
Tusk creates your test execution environment by:
- Creating a Dockerfile (or Docker Compose for projects needing databases/services)
- Writing setup scripts to install dependencies
- Writing test scripts configured for your framework
- Verifying everything works by running your tests
- Iterating if any issues are found
Answer questions (if needed)
During setup, Tusk may ask clarifying questions about your configuration:
- Which test command to use if multiple are available
- How to handle specific dependencies
- Confirmation of environment variable requirements
Need to make changes? You can update your test execution environment(s) at any time. Just describe what you’d like to change and Tusk will modify and re-verify the configuration.
See below for context.
Configuration Components
Each test execution environment consists of several components that Tusk configures automatically during setup.Environment Definition
You’ll have either a Dockerfile or a Docker Compose configuration depending on your project’s needs. Dockerfile - For most projects where tests only need the application runtime and mock external services. Docker Compose - For projects where tests need real service dependencies (databases, Redis, etc.). Tusk analyzes your repository and CI configuration to automatically determine which approach is best for your project.Scripts
| Script | Purpose |
|---|---|
| Setup | Installs dependencies and prepares the environment |
| Test | Runs tests for a specific file |
| Lint | (Optional) Runs formatting/linting and build checks |
| Coverage | (Optional) Collects test coverage data |
Configuration Settings
| Setting | Description |
|---|---|
| Test Framework | The testing framework detected |
| App Directory | For monorepos, the subdirectory containing your service |
| Test File Regex | Pattern for matching test files in your codebase |
Viewing Your Configuration
To view an existing test execution environment:- Go to the Unit Tests page
- Click on your repository
- Select the Test Execution Environments tab
- Click on an environment, then select the Configuration tab
- The complete Dockerfile or Docker Compose file
- All setup, test, lint, and coverage scripts
- Environment variables (non-secret values only)
- Test file pattern and other settings
Updating Configuration
If you need to modify your test execution environment:- Navigate to the environment in the Tusk UI
- Click Update
- Describe what you’d like to change
- Tusk will update and re-verify the configuration
- Adding new system dependencies
- Changing test commands or flags
- Enabling coverage collection
- Adding support for new services (databases, caches)
- Fixing issues with environment setup
Tusk verifies updates by running your tests, so you’ll know immediately if the changes work.
Environment Variables
Test environments often need environment variables. Some examples include:- NPM tokens for private packages
- Database passwords or connection strings
- Third-party service credentials
Managing Environment Variables
- Go to Repository Settings > Environment Variables
- Click Add Variable
- Enter the key, value, and mark as “Secret” if sensitive
- Variables are automatically available in all test environments for that repo
When Tusk Asks for Variables
During setup or updates, Tusk may detect that environment variables are needed. You’ll see a prompt asking for specific variables with context about why they’re needed. You can:- Provide the values now to ensure setup succeeds on the first try
- Skip for now - setup continues and Tusk will ask again if tests fail due to missing variables
Multiple Environments (Monorepos)
For monorepos with multiple services, you can have separate test execution environments - one per service directory (e.g.,packages/api, packages/web). Each environment has its own Dockerfile and scripts, can use different test frameworks, and runs independently.
During repository analysis, Tusk identifies each testable directory and lets you set them up individually.
Resources and Performance
Tusk automatically allocates and manages resources for your test environment. If you’re experiencing slowdowns or timeout issues, contact support@usetusk.ai to discuss resource tuning.FAQs
What happens if test environment setup fails?
What happens if test environment setup fails?
If setup encounters an issue it can’t resolve automatically, you’ll see a “Failed” status with details about what went wrong. You can:
- Review the error - Click into the environment to see the specific failure
- Provide missing information - Often failures are due to missing environment variables or unclear configuration
- Retry setup - After addressing the issue, click Retry to start again
- Contact support - For complex issues, reach out to support@usetusk.ai
How do I update an existing test environment configuration?
How do I update an existing test environment configuration?
You can update any test execution environment at any time:
- Go to the Unit Tests page and click on your repository
- Select the Test Execution Environments tab
- Click on the environment you want to modify
- Click Update and describe what you’d like to change
Can I have multiple test environments for a monorepo?
Can I have multiple test environments for a monorepo?
Yes! During repository analysis, Tusk identifies each directory that contains tests. You can set up separate test execution environments for each service or package in your monorepo.Each environment has its own Dockerfile, scripts, and configuration - they run independently when Tusk generates tests for changes in that directory.