Skip to content
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

flushHeaders is not implemented on response mock #312

Closed
RobinTail opened this issue Dec 6, 2024 · 3 comments · Fixed by #313
Closed

flushHeaders is not implemented on response mock #312

RobinTail opened this issue Dec 6, 2024 · 3 comments · Fixed by #313

Comments

@RobinTail
Copy link
Contributor

TypeError: response.type(...).setHeader(...).setHeader(...).flushHeaders is not a function

It should just set headersSent on response, as per my understanding

@RobinTail
Copy link
Contributor Author

As a workaround writeHead() method can be used instead of type() +setHeader() + flushHeaders() ones.

@RobinTail
Copy link
Contributor Author

RobinTail commented Dec 6, 2024

But writeHead does not set headersSent prop to true in the mocked implementation.

mockResponse.writeHead = function writeHead(statusCode, statusMessage, headers) {

I think it should https://nodejs.org/api/http.html#responsewriteheadstatuscode-statusmessage-headers

@RobinTail
Copy link
Contributor Author

I checked manually to ensure the actual behaviour of writeHead() and it really does set headersSent to true, because it sends the headers. So I made a PR to fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant