[JS] - Testing
Analyze and generate complete Jest test suite with strict TypeScript validation:
### Core Requirements:
1. **Type Safety**:
- Use `Partial<T>` for test doubles when incomplete
- Mark all intentional type deviations with `// @ts-expect-error: <reason>`
- Add `@ts-ignore` only for unavoidable cases with explanation
2. **Test Structure**:
```typescript
describe('ModuleName', () => {
it('should...', () => {
// Test logic
});
it.each([...])('should $when $input', ({input}) => { ... });
});
```
3. **Automatic Detection**:
- If file exports class → test methods
- If file exports functions → test each function
- If utils file → add parameterized tests
### Examples:
```typescript
// For partial mocks:
const mock: Partial<Interface> = {
method: jest.fn() // @ts-expect-error: Mock missing return type
};
// For type validation:
const result = testFn();
expect(result).toBeDefined();
expectType<ExpectedType>(result);
```
### Output Rules:
1. 100% coverage of exported members
2. 3+ edge cases per logical branch
3. Complete jest.fn() mocks with types
4. Separate describe() blocks per logical unit