express.methods() no longer available
The line
methods = require('express').methods
in index.js fails against the most recent version of Express. I can get this module to work fine by simply hard-coding an array ['get','post',..] etc. but is there some better way to do this now? I note this repo has not been updated in a while.
More detailed example of a work-around. I added this to to the top of my test file:
var express = require('express');
express.methods = [ 'get', 'post', 'delete' ];
I thought this was merged into the main repo, but having the same issue myself...
also still having the issue
The README for this project states that the code came from the express test suites. The link it provides is now broken, but looking into the test suites it looks like they now use supertest (or at least there are tests that use supertest). That library is somewhat different as it actually listens on a port and sends a real HTTP request (if I understand correctly).
However, for me that serves my purpose, as I only want a small number of tests at this level, as I'm testing express middleware that will delegate to other functions that I can unit test in isolation. (I'd suggest that anyone who has a reason to look for mock request objects consider whether they can have a thin layer that extracts the data they need from the request object and pass just that extracted data on to other simpler functions that are easier to test. Then you only need a small number of tests to test that thin layer. Of course there will be exceptions though...)