-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add support for Express apps #11
Comments
I recall looking in to this back when I was writing the library, and in the end decided the more explicit form is safer. If I recall correctly, supertest itself has a subtle bug if you pass an express app in and rely on it starting & stopping the server for you (I'll see if I can find the issue for it. Vaguely remember something about a race condition causing tests to occasionally fail…) |
Ah; found it (easy to find because I raised it!): ladjs/supertest#566 See also the linked issues for that; at least at the time (and maybe still?), supertest never closed servers started this way, so as your tests run you will gradually build up more and more servers listening on different ports! It's a pity that style is the one they push in the readme because it's really quite problematic! |
I added a section to the readme to explain this decision in detail and updated the error thrown by the library to include a link to it. So for now I'm going to close this as won't-fix. I think at the very least, adding this feature would depend on ladjs/supertest#566 being fixed first, but even with that fixed, it would need to be possible to reliably know when the test has finished to avoid leaving the test runner hanging (requiring the user to add an Feel free to re-open if you have any suggestions on how to support this safely. |
In order to make the API more closely aligned with supertest, add support for the Express apps.
supertest
makes it possible to write:When doing this,
supertest
starts the server before running the tests and closes it at the end.superwstest
currently requires this to be done externally inbeforeEach
andafterAll
blocks. Mimicking whatsupertest
does would make it easier for people who come fromsupertest
to pick upsuperwstest
.The text was updated successfully, but these errors were encountered: