Testing Tdd London Error Handling

Sub-skill of testing-tdd-london: Error Handling.

vamseeachanta Updated

File contents

Error Handling

Error Handling

Missing Mock Verification

// Always verify mocks were called as expected
afterEach(() => {
  // Fail if any mock was called unexpectedly
  expect(unexpectedCallsDetected()).toBe(false);
});

// Use strict mocks
const strictMock = jest.fn().mockImplementation(() => {
  throw new Error('Unexpected call');
});

Mock Leakage Between Tests

// Always reset mocks
beforeEach(() => {
  jest.clearAllMocks();  // Clears call history
  // or
  jest.resetAllMocks();  // Also resets implementation
});

vamseeachanta/workspace-hub/tree/main/.agents/skills/_archive/development/testing/testing-tdd-london/error-handling commit 223c5e49c6

Frequently asked questions

npx skillmds@latest add vamseeachanta/testing-tdd-london-error-handling