jestjs
只是包装纸而已
jasmine
在许多情况下,它依赖于
jasmine
的规则。
因此,你可以利用
the same
done
callback
传给
test
功能:
test(`Create an actor ${actorsUrl}`, async (done) => {
const response = await request(app.callback())
.post(actorsUrl)
.send(params)
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
.expect(200)
expect(response.body.name).toBe(params.name)
expect(response.body.address).toBe(params.address)
actorId = response.body.id
done();
})
test(`Get the actor created ${actorsUrl}/${actorsUrl}`, async (done) => {
const response = await request(app.callback())
.get(`${actorsUrl}/${actorsUrl}`)
.set('Accept', 'application/json')
.expect(200)
expect(response.body.name).toBe(params.name)
expect(response.body.address).toBe(params.address)
done();
})
你可以在笑话里读到更多
async documentation