Jest Utility Test Skill
Whenever Copilot encounters a utility or helper function (e.g., string manipulation, math operations, data formatting), it should generate a corresponding Jest test file.
- •Place the test file alongside the utility in the same folder, named
<filename>.test.js. - •Ensure tests cover normal cases, edge cases, and error handling.
- •Use
describeblocks for grouping andtestblocks for individual cases. - •Keep tests concise, readable, and aligned with Jest best practices.
- •If the function throws errors, include
toThrowassertions. - •If the function handles arrays or objects, include tests for empty and malformed inputs.
- •Include atleast one edge case.
- •For number inputs, test with value -1, 0, undefined. Update function if these edge cases are not handled.