-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global keepOpen() #246
Comments
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} */
let baseUrl;
before(async () => {
baseUrl = await server.start(); // where this starts the server and returns something like 'http://localhost:5000'
});
after(async () => server.close());
it('should test something', async () => {
const res = await chai.request(baseUrl).get('/first');
// ...
});
it('should test another thing', async () => {
const res = await chai.request(baseUrl).get('/second');
// ...
});
}); Though normally, in my opinion, it's better to have each |
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: