Fixing failing tests
Give Claude Sonnet 4.6 the failing test, the error and the function under test, and have it propose the smallest fix. Rerun the full test suite before merging.
Example: Why does this test fail?
Material
- Test
- expect(slugify('Hello, World!')).toBe('hello-world')
- Function
- const slugify = (s) => s.toLowerCase().replace(/ /g, '-');
- Error
- Expected 'hello-world', received 'hello,-world!'
PromptExplain why the test fails and give the smallest change that fixes it.
Sample answer · written by hand to show the reasoning
The function only replaces spaces, so the comma and exclamation mark stay in the result. Remove anything that is not a letter, digit or space first: s.toLowerCase().replace(/[^a-z0-9 ]/g, '').trim().replace(/ +/g, '-'). That returns 'hello-world' and also collapses double spaces.