Comments (11)
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.
HI @siavol, could you please check if version 1.11.0 has the same behaviour?
from node-mocks-http.
@eugef , I confirm that 1.11.0 has the same behaviour.
from node-mocks-http.
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.
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.
Thank you! I am ready to take care of this issue. Going to provide PR in a few days.
from node-mocks-http.
I've prepared a pull request: #263
from node-mocks-http.
Stale issue message
from node-mocks-http.
@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.
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.
Stale issue message
from node-mocks-http.
Related Issues (20)
- TypeError: Cannot read property 'pipesCount' of undefined and TypeError: req.resume is not a function HOT 1
- Typescript: Type 'string' is not assignable to type 'Body | undefined' HOT 3
- `_isJSON()` doesn't recognize `application/*+json`. HOT 4
- `res.send()` doesn't convert to string HOT 7
- request.getHeader() missing? HOT 3
- How to use custom request in express using node-mocks-http ? HOT 9
- Parameters mismatch Typescript definitions HOT 15
- Please tag 1.10.1 HOT 1
- version 1.11.0 not available on NPM HOT 1
- Why is baseUrl non-empty? HOT 5
- Response "close" event is not emitted HOT 1
- Testing Next.js, can't get _getJSONData() HOT 9
- Make a release for last merged PR HOT 1
- Setup Travis CI HOT 2
- @types/express 3.17.15 -> Request/Response mismatch HOT 5
- Importing produces ESlint warning `import/named` HOT 7
- Timeouts when using with formidable HOT 1
- Tests started to fail when using node 16 to run then and works when use node 14 HOT 1
- Provide decorator for stream consumer through pipe HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-mocks-http.