-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Following the The README documentation of an async test against a mockserver and trying to apply that to remote API I'm finding it doesn't run the assertions (doesn't await?).
Here is the example from the README
it('demo test', async function(client) {
const req = await server.request()
.post('/api/v1/datasets/')
.send({name: 'medea'})
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/);
await client.assert.deepStrictEqual(server.route.post('/api/v1/datasets/').requestBody, {name: 'medea'});
});If I modify that to talk to a remote API like the demo Swagger Petstore API it doesn't await on the expects so it will pass regardless of the expect
it('pet store test', async function({supertest}) {
const req = await
supertest
.request('https://petstore.swagger.io/v2')
.get('/store/inventory')
.set('Accept', 'application/json')
.expect(200) // For example, if I change this to 400 it will still pass
.expect('Content-Type', /json/);
});If I instead use a non-async pattern it correctly checks the assertions
it('pet store test2', function({supertest}) {
supertest
.request('https://petstore.swagger.io/v2')
.get('/store/inventory/')
.expect(200) // If I change to 400 it will fail as expected
.expect('Content-Type', /json/)
.end(function() {
console.log('done');
});
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels