Skip to content

Instantly share code, notes, and snippets.

@RobertBrewitz
Created June 10, 2020 17:49
Show Gist options
  • Save RobertBrewitz/5b8c56bc54f17c0a0bd87b6c8c6dbef5 to your computer and use it in GitHub Desktop.
Save RobertBrewitz/5b8c56bc54f17c0a0bd87b6c8c6dbef5 to your computer and use it in GitHub Desktop.
Acquiring Express Router routes
const req = { method: 'POST', path: '/' };
const res = { send: jest.fn() }
const request = (req, res) => {
return jobs.stack
.find((layer) => {
return (
layer.route.path === req.path &&
layer.route.methods[req.method.toLowerCase()]
);
})
.handle(req, res);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment