You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is the a way to ensure keepOpen() is the default during a run, rather than needing to specify it every time? If this is already there, then I seem to have missed it.
Thinking of something like:
chai.use(chaiHttp({ keepOpen: true }));
I had previously been using 'supertest' and then was surprised to see my server closing between every test. In my case I am doing a full life-cycle test and keeping open is necessary and I wouldn't be expecting my test library to be impacting the running state of my express server.
The text was updated successfully, but these errors were encountered:
Hi @ajmas! I don’t think there is currently a way to keep the server open by default, though it would only be closed if you are passing it to chaiHttp instead of using the URL option. Assuming you're using a mocha-like framework, could you do something like:
describe('open server',()=>{/** @type {string} */letbaseUrl;before(async()=>{baseUrl=awaitserver.start();// where this starts the server and returns something like 'http://localhost:5000'});after(async()=>server.close());it('should test something',async()=>{constres=awaitchai.request(baseUrl).get('/first');// ...});it('should test another thing',async()=>{constres=awaitchai.request(baseUrl).get('/second');// ...});});
Though normally, in my opinion, it's better to have each it test be totally independent of all other tests - it can be tough to reproduce when there is some implicit ordering between tests.
Is the a way to ensure
keepOpen()
is the default during a run, rather than needing to specify it every time? If this is already there, then I seem to have missed it.Thinking of something like:
I had previously been using 'supertest' and then was surprised to see my server closing between every test. In my case I am doing a full life-cycle test and keeping open is necessary and I wouldn't be expecting my test library to be impacting the running state of my express server.
The text was updated successfully, but these errors were encountered: