I want to set up a request once and then use it in multiple tests. This was the best way I could come up to do that, but it seems odd to have to have to declare req
mutable just so it will be available in an outside scope.
describe('GET /password', () => {
let req
before(() => {
req = chai.request(app).get('/password')
return req
})
it('should get the password page', () => {
return req.then(res => res.should.have.status(200))
})
describe('The password page', () => {
it('should render HTML', () => {
return req.then(res => res.should.be.html)
})
})
})
I was hoping I could do something like
const req = before(() => {
return chai.request(app).get('password')
})
... but it seems that before()
does not return the value returned in its callback.
Is there a better (more "elegant") way to do this?