clearServiceMocks function

void clearServiceMocks()

Removes all interceptors registered with mockService.

Call this in tearDown or via addTearDown to ensure a clean state between tests:

setUp(() {
  mockService<UserCreateService>(Failure('unauthorized'));
  addTearDown(clearServiceMocks);
});

Use it directly when you need to clear mocks mid-test:

it('falls back to real service after mock is cleared', () {
  mockService<UserCreateService>(Failure('unauthorized'));
  clearServiceMocks();
  expect(UserCreateService(name: 'Alice', email: 'alice@test.com').call(),
      haveSucceededWith('userCreated'));
});

Implementation

void clearServiceMocks() => serviceInterceptors.clear();