Use TestDriver in GitHub
TestDriver works directly in GitHub’s web interface and mobile app. The same MCP server that powers VS Code integration also works in GitHub, letting you create and manage tests from anywhere.How It Works
When you add a TestDriver agent file to your repository at.github/agents/testdriver.agent.md, GitHub Copilot can use TestDriver’s MCP tools directly in:
- GitHub.com (web browser)
- GitHub Mobile app (iOS/Android)
- Pull request conversations
- Issue comments
Using TestDriver in GitHub Web
1
Navigate to Your Repository
Open your repository on GitHub.com. Make sure you have the TestDriver agent file at
.github/agents/testdriver.agent.md.2
Start a Copilot Chat
Click the Copilot icon in the GitHub interface to open a chat. You can find this in:
- The repository’s Code tab
- Pull request pages
- Issue pages
3
Invoke the TestDriver Agent
Start your message with The agent will spawn a sandbox environment and begin executing, just like in VS Code.
@testdriver:4
View Screenshots in Chat
As the test runs, screenshots appear directly in the chat. You can see what the AI sees and provide guidance if needed.
Creating Tests from PR Comments
You can create tests directly from pull request reviews. Comment on a PR and mention Copilot:- Use the TestDriver MCP server
- Create a test based on your description
- Commit the test file to the PR branch
- Adding test coverage during code review
- Verifying bug fixes before merging
- Creating regression tests for new features
Creating Tests from Issues
You can also create tests from issue comments:Mobile App Support
The GitHub Mobile app supports Copilot chat, which means you can use TestDriver from your phone:- Open the GitHub app
- Navigate to your repository
- Tap the Copilot icon
- Type
@testdriverfollowed by your request
Example: PR Review Workflow
Here’s a complete workflow for adding tests during code review:1
Developer Opens PR
A developer opens a pull request with a new feature.
2
Reviewer Requests Tests
The reviewer comments:
3
Copilot Creates Tests
Copilot spawns TestDriver, creates the tests, and commits them to the PR branch.
4
Tests Run in CI
The new tests run automatically in CI, validating the feature works as expected.
Agent File Reference
The agent file at.github/agents/testdriver.agent.md contains the configuration for GitHub Copilot to use TestDriver. Here’s the structure:
TD_API_KEY is pulled from your repository secrets when running in GitHub Actions or from your environment when using the web interface.
Auto-Healing Tests
Auto-healing tests automatically fix themselves when your application changes. By integrating an AI coding agent with TestDriver in your CI pipeline, you can have AI investigate test failures and propose fixes. The example below uses GitHub Copilot in GitHub Actions, but the same approach works with any AI agent that can run TestDriver’s MCP server.How It Works
When a test fails in CI:- GitHub Actions detects the failure
- The AI agent spawns TestDriver with access to the MCP server
- The agent investigates by running the failing test and analyzing what changed
- The agent creates a fix by updating the test code
- A pull request is opened with the proposed changes for review
Setting Up Auto-Healing
1
Add Repository Secrets
Add your TestDriver API key to your repository secrets:
- Go to Settings → Secrets and variables → Actions
- Click New repository secret
- Add
TD_API_KEYwith your API key value
2
Create the Auto-Heal Workflow
Add a GitHub Actions workflow that triggers on test failures:
.github/workflows/auto-heal.yml
3
Configure Test Workflow
Make sure your main test workflow has a name that matches the
workflows trigger:.github/workflows/tests.yml
Example: Button Text Change
Here’s what auto-healing looks like when a button’s text changes:1
Application Changes
A developer changes a button’s text from “Submit” to “Send”:
2
Test Fails
The test fails because it’s looking for the old text:
3
Auto-Heal Triggers
The auto-heal workflow runs, and the AI agent investigates:
4
PR Created
A pull request is opened with the fix:
Configuration Options
Selective Auto-Healing
You can limit auto-healing to specific test files or patterns:Manual Approval
For safety, you can require manual approval before auto-heal runs:Limiting Changes
Add instructions to constrain what the AI can change:Best Practices
Always review auto-heal PRs
Always review auto-heal PRs
Auto-heal is a tool, not a replacement for human judgment. Review all changes before merging to ensure the test still validates what you intended.
Use descriptive element descriptions
Use descriptive element descriptions
Tests with clear, semantic descriptions are easier for the AI to heal:
Set up notifications
Set up notifications
Configure GitHub notifications or Slack integration to be alerted when auto-heal PRs are created.
Track heal rate
Track heal rate
Monitor how often tests need healing. High heal rates may indicate:
- Tests are too brittle
- Application is changing rapidly
- Element descriptions need improvement
Limitations
Auto-healing works best for:- Element text changes
- Layout and styling updates
- Minor UI restructuring
- Major workflow changes
- New features requiring new assertions
- Complex multi-step interactions
View Your Runs
Open the TestDriver console to monitor test runs, healing PRs, and CI results across your projects.

