You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is this issue currently blocking your project? (yes/no): no
is this issue affecting a production system? (yes/no): no
Context
node version: any
module version: 8.0.3
environment (e.g. node, browser, native): node
used with (e.g. hapi application, another framework, standalone, ...):
any other relevant information:
What problem are you trying to solve?
To test for the .code property attached to node errors (instead of .message) that are not fixed).
Currently I have to do this manually, eg. for throw():
constCode=require('code');constexpect=Code.expect;consterr=expect(()=>process.chdir(42)).to.throw(TypeError);expect(err).to.contain({code: 'ERR_INVALID_ARG_TYPE'});// or as one-linerexpect(expect(()=>process.chdir(42)).to.throw(TypeError)).to.contain({code: 'ERR_INVALID_ARG_TYPE'});
Do you have a new or modified API suggestion to solve the problem?
Add a third has parameter to throw() and reject(), which takes an object which is passed to a contain() test. Also make the message optional (works since it uses a string and type must be instanceof Error). Eg.
Support plan
Context
What problem are you trying to solve?
To test for the
.code
property attached to node errors (instead of.message
) that are not fixed).Currently I have to do this manually, eg. for
throw()
:Do you have a new or modified API suggestion to solve the problem?
Add a third
has
parameter tothrow()
andreject()
, which takes anobject
which is passed to acontain()
test. Also make themessage
optional (works since it uses a string and type must beinstanceof Error
). Eg.The text was updated successfully, but these errors were encountered: