-
Notifications
You must be signed in to change notification settings - Fork 761
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
npm supertest intercepts middleware and does not run boot scripts #298
Comments
Latest Finding: if we add the following code snippet for the unit tests, they actually pass Reference in server.js : start function Reference in server.js : stopServer function Although, we shouldn't be required to start and stop a server since that's the job of supertest; but this to some extent confirms the issue of 'res' being undefined because the supertest server shuts down early? Is this a bug in supertest? Thoughts? |
@varunj90 I actually don't think that supertest is responsible for setting up and tearing down an api server. The few examples in the README.md include express and set up a quick express server for the sake of a quick demo. supertest is a wrapper around superagent and handles making requests and evaluating responses, but not the actual server. |
We are registering our middleware handler in server/middleware.json like the following:
When performing integration tests using supertest :
the code does not go through our middleware which contains the error handler because of which we get errors like
here11111111111111111111111111111111111111111111:
{ [Error: Parse Error] bytesParsed: 9, code: 'HPE_INVALID_STATUS', response: undefined }
OR
here11111111111111111111111111111111111111111111:
[TypeError: Cannot read property 'header' of undefined]
We suspect that we have a missing configuration with supertest ;
or
We might need some code that starts up in server.js that links supertest properly using loopback.
Can you advice us on getting this to work as it is a major roadblock.
Thank you !
The text was updated successfully, but these errors were encountered: