Debugging failing tests
Send the failing test output and the code it covers, and have Grok 4.5 explain the cause and propose the smallest fix. Run the full test suite on the fix before merging.
Example: Why does this test fail after the refactor?
Material
- Test output
- expected formatPrice(1999) to be "$19.99", received "$1999.00"
- price.ts
- export const formatPrice = (amount: number) => `$${amount.toFixed(2)}`;
- Commit message
- Refactor: prices are now stored in cents everywhere.
PromptUsing the test output and the function, explain why the test fails and give the smallest fix.
Sample answer · written by hand to show the reasoning
Prices are now stored in cents, but formatPrice still treats its argument as dollars, so 1999 cents prints as $1999.00. Divide by 100 before formatting: `$${(amount / 100).toFixed(2)}`. Search for other callers that already divide by 100, or they will now be off by a factor of 100 in the other direction.