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

Associate a req with res and vice versa #45

Closed
jasonkarns opened this issue Mar 10, 2015 · 8 comments
Closed

Associate a req with res and vice versa #45

jasonkarns opened this issue Mar 10, 2015 · 8 comments

Comments

@jasonkarns
Copy link
Contributor

req.res should exist, as should res.req.

I'm not sure if there should be a single api method that creates both req and res under the hood (and returns both as array? or object? or just one or the other?)

Or if the createRequest/createResponse methods should accept the other half of the pair and do the wireup?

Or if there should be a separate utility method that just accepts already-created req/res mocks and associates them.

Thoughts?

I'd be happy to work on the PR, once a direction is decided that fits the goals of the project.

@estilles
Copy link

@jasonkarns, thanks for pointing this out.

I think your last suggestion is the way to go. We should probably simulate the way Express does it at the moment. Express assigns these to each other at the beginning of the middleware lifecycle, in the init middleware.

Regardless of how we do it, I suspect this will be a breaking change.

If we find a way to enable the feature without introducing any breaking changes, we will likely include it in the 1.3 release. Otherwise, it will have to wait until the 2.0 release. (See milestones.)

We're open to suggestions, so if you have any ideas on how to enable this feature without an breaking changes, by all means share them with us. If you decide to submit a PR, please read our new contributing guidelines.

Soon we will be publishing the roadmap for our 2.0 release. I suspect this feature will be part of that roadmap.

@jasonkarns
Copy link
Contributor Author

So something like: httpMocks.init(mockReq, mockRes);

@estilles
Copy link

Actually, after studying the Express 4.x I noticed we're missing a number of other object references. We intend to mimic Express' structure as much as we can. We've scheduled these changes for version 2.x.

@jasonkarns
Copy link
Contributor Author

Where does this leave this issue? I don't see a 2.x branch in development or anything. Does this mean you don't want any PR for it?

@estilles estilles reopened this Mar 25, 2015
@estilles
Copy link

1.3 will be out in a few days with a number of additions in preparation for 2.0. The 2.x branch will be out shortly after that. You're welcome to contribute.

@jasonkarns
Copy link
Contributor Author

Cool. I'll wait till then to do any work on it.

@estilles
Copy link

estilles commented Apr 2, 2015

@jasonkarns, I've added our roadmap for our 2.0 release (issue #54). It is a complete overhaul of node-mocks-http, which includes a solution for this issue.

@github-actions
Copy link

Stale issue message

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

No branches or pull requests

2 participants