Description
Current behavior
Currently, if a falsy, but not undefined
, value is passed as a static response such as req.reply({ body: false })
, the boolean value is dropped by the net-stubbing backend. This behavior does not match up with the behavior for true
, where req.reply({ body: true })
will return true
.
Desired behavior
At the very least, there should be consistency in how net-stubbing handles boolean values. I see two reasonable options:
- Return falsy static responses. This would provide consistent behavior with truthy values of the same type.
- Throw a runtime error when non object or string values are used as static responses. Currently, when falsy values are dropped, a response is returned without any indication that something went wrong.
I think the first option is the preferable one, and while the type definition for static responses only includes strings and JSON objects, I expect others might also be implicitly relying on req.reply
to handle other types like boolean
s or numbers
.
I have a branch that adds a couple undefined
checks in place of truthy checks
that would match fix #1.
Test code to reproduce
This is a test case that describes the current behavior.
Versions
Cypress 6.x