Copilot prompt
Write Unit Tests from Signatures
Generate unit tests from function signatures and types with edge cases and meaningful assertions.
Generate a complete unit test file for these function signatures. ## Functions to test: ```{{language}} {{function_signatures}} ``` ## Test framework: {{test_framework}} ## Mocking library: {{mock_library}} ### Test Generation Rules For each function: **1. Infer Behavior from Signature** Look at: parameter types, return type, function name. What does this function probably do based on its contract? **2. Write these test categories:** **Happy Path Tests** (at least 2 per function) - Typical valid inputs with expected outputs - Use realistic data, not "foo" or "bar" **Edge Case Tests** (at least 3 per function) - Empty inputs: empty string, empty array, empty object - Boundary values: 0, -1, MAX_SAFE_INTEGER, very long strings - Type boundaries: what happens at the edge of valid input? **Error/Rejection Tests** (at least 2 per function) - null and undefined inputs - Invalid type inputs (where TypeScript doesn't protect at runtime) - Out-of-range values **3. Test Format** ```{{test_framework}} describe('functionName', () => { it('should [behavior] when [condition]', () => { // Arrange const input = ...; // Act const result = functionName(input); // Assert expect(result).toBe(expected); }); }); ``` **4. Mocking** For any external dependencies: mock them with {{mock_library}}. Each test should be independent — reset mocks in beforeEach. Output complete test file ready to run.
Fill in: {{language}}, {{function_signatures}}, {{test_framework}}, {{mock_library}}. In Loopy you fill these in a form and copy the finished prompt in one click.

