code_test_for
code_test_for searches test files for references to a given function or method and returns the test files and specific test cases that cover it.
code_test_for(name="PaymentService.charge")code_test_for(name="processPayment", include_code=true)Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | required | Function or method name |
include_code | boolean | false | Include the test code snippets alongside file paths |
Output
Section titled “Output”PaymentService.charge — covered by 2 test files:
tests/payment.test.ts "should charge successfully" :14 "should throw on invalid card" :31 "should retry on timeout" :48
tests/integration/checkout.test.ts "full checkout flow" :22When to use
Section titled “When to use”- Before modifying a function — find what tests already cover it
- After writing a new function — verify the expected tests exist
- During a refactor — know which tests to run to confirm nothing regressed
Workflow
Section titled “Workflow”# Find what covers a functioncode_test_for(name="PaymentService.charge")
# Run only those testscode_test(filter="payment")
# Confirm all pass after changescode_test(filter="payment")