Line 149 of lib/mockResponse is checking if (typeof data === 'object') before trying to extract any values out of data, but if you do something like res.status(303).send(null) to send a response without a body, it will bypass this check and cause a TypeError as it tries to extract values out of null. Because typeof null is broken in Javascript and returns 'object', so it passes this check. The TypeError then occurs on line 151 where it is trying to retrieve the statusCode from null, even though the statusCode of the response could have been set with .status().
Line 149 of lib/mockResponse is checking
if (typeof data === 'object')
before trying to extract any values out ofdata
, but if you do something likeres.status(303).send(null)
to send a response without a body, it will bypass this check and cause a TypeError as it tries to extract values out of null. Becausetypeof null
is broken in Javascript and returns 'object', so it passes this check. The TypeError then occurs on line 151 where it is trying to retrieve the statusCode from null, even though the statusCode of the response could have been set with.status()
.