Skip to content

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)
ParameterTypeDefaultDescription
namestringrequiredFunction or method name
include_codebooleanfalseInclude the test code snippets alongside file paths
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" :22
  • 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
# Find what covers a function
code_test_for(name="PaymentService.charge")
# Run only those tests
code_test(filter="payment")
# Confirm all pass after changes
code_test(filter="payment")