Writing Integration Tests
What aspect of API testing does this code demonstrate?
const agent = supertest(app);
describe('API Integration', () => {
it('should create and retrieve a resource', async () => {
const createResponse = await agent
.post('/api/items')
.send({ name: 'Test Item' })
.expect(201);
const itemId = createResponse.body.id;
const getResponse = await agent
.get(`/api/items/${itemId}`)
.expect(200);
expect(getResponse.body.name).toBe('Test Item');
});
});