Trunk can automatically investigate flaky tests in your codebase and raise fix pull requests with suggested solutions.Documentation Index
Fetch the complete documentation index at: https://trunk-4cab4936-mintlify-sync-from-docs-1778014214.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
To use the Autofix Flaky Tests feature, you’ll need:- Beta access via waitlist (reach out to us on Slack)
- The “Investigate Flaky Tests” setting enabled in your workspace
- Active installation of the Trunk GitHub App
Auto-Investigate Flaky Tests
Once enabled, any time that Trunk detects a flaky test, Trunk analyzes the failure patterns, failure output, and git history of the test to provide a number of insights. Flaky tests can also be analyzed manually via the UI and via the MCP server.Autofix with Cursor Automations
Whenever an investigation is completed, Trunk will emit a webhook fortest_case.investigation_completed. Enable webhooks via Svix.
You can then set up a Cursor Automation to trigger when webhooks are received.
Recommended Cursor Automation Config
Recommended Cursor Automation Config
- Version your Automation names for more clarity.
- Configure the Svix endpoint with the Cursor Bearer token.
- Webhooks are configured for your entire organization, so you will need to use Svix transformations or filter out events that are not for your intended repository.
- Be specific about conventions and antipatterns for your repository. You will need to refine the Automation prompt to suit your needs.
- If your CI setup allows it, prompt Cursor to run the tests to verify them.
What’s next?
- Continue to monitor your tests to confirm the flaky test fixes are effective
- Investigations can be triggered and applied via MCP
Coming soon. Set up Claude Routines to autofix flaky tests