Writing Integration Tests
What testing approach is shown for external API dependencies?
describe('Third-party API integration', () => {
const apiKey = process.env.API_KEY;
let recorded;
beforeAll(() => {
recorded = nock('https://api.example.com')
.get('/data')
.reply(200, { status: 'success' });
});
test('should handle API responses', async () => {
const result = await thirdPartyService.getData();
expect(result.status).toBe('success');
expect(recorded.isDone()).toBe(true);
});
});