Code Monkey home page Code Monkey logo

Comments (11)

eugef avatar eugef commented on August 16, 2024 1

Github bot regularly closes stale issues and PRs

The issue still exists, you can help fixing it by improving this PR #263

from node-mocks-http.

eugef avatar eugef commented on August 16, 2024

HI @siavol, could you please check if version 1.11.0 has the same behaviour?

from node-mocks-http.

siavol avatar siavol commented on August 16, 2024

@eugef , I confirm that 1.11.0 has the same behaviour.

from node-mocks-http.

siavol avatar siavol commented on August 16, 2024

I took a look at the code and it is pretty straightforward to not allow setting headers after they are sent to the client. But mockResponse.send does not set any headers, so that change will be not enough. Also method docs explicitly says that send can be called multiple times. I wonder what is the reason of this decision?

from node-mocks-http.

eugef avatar eugef commented on August 16, 2024

That code was written almost 8 years ago, so not sure if we can figure out the reason.

The proper behaviour for the mock would be to throw the same type of error.
If you can create a PR with the fix - your help will be much appreciated.

from node-mocks-http.

siavol avatar siavol commented on August 16, 2024

Thank you! I am ready to take care of this issue. Going to provide PR in a few days.

from node-mocks-http.

siavol avatar siavol commented on August 16, 2024

I've prepared a pull request: #263

from node-mocks-http.

github-actions avatar github-actions commented on August 16, 2024

Stale issue message

from node-mocks-http.

HartS avatar HartS commented on August 16, 2024

@eugef do you know why this issue (and corresponding PR) were closed? I realize the PR itself didn't get feedback addressed, but this is still an issue, right?

from node-mocks-http.

HartS avatar HartS commented on August 16, 2024

Thanks @eugef . I'm kind of just getting familiar of the ergonomics of using this library.

I assume it's also be possible to spy on the res.send function to ensure it's not called more than once, and now I'm wondering if it's better to have the flexibility to allow some tests to send more than once (for example, I have req and res regenerated in a beforeEach, but if I wanted to run through the same middleware I'm testing twice in the same test, then it might be useful that res.send can be called twice)

Feel free to close, and I may re-open with a PR that makes sense to me once I have a better idea of how people might be using this. Perhaps an additional method to enable the error on sending twice is the best approach, since that would make it a non-breaking change for people who might be relying on being able to send multiple times with the same res object.

from node-mocks-http.

github-actions avatar github-actions commented on August 16, 2024

Stale issue message

from node-mocks-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.