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
assert.throws(function(){const[a,b,c,d]=foo('oh yes');},/Argumentisrequiredatargumentindex=1,buttypewaswrong/,'did not throw with expected message');
the above is fine, no error is thrown because the block does throw an error with a message that matches the regex
however, if I do this, I get something unexpected (I changed the regex):
assert.throws(function(){//block argconst[a,b,c,d]=foo('oh yes');},/Argumentisrequiredatargumentindex=2,buttypewaswrong/,//error arg'did not throw with expected message');//message arg
it will give me this:
Error: Argument is required at argument index = 1, but type was wrong
=> expected => "object"
=> actual => "undefined"
at Object.parse (/Users/t_millal/WebstormProjects/oresoftware/pragmatik/index.js:250:19)
at foo (/Users/t_millal/WebstormProjects/oresoftware/pragmatik/test/test-src/parse-to-array/three.test.js:31:26)
at /Users/t_millal/WebstormProjects/oresoftware/pragmatik/test/test-src/parse-to-array/three.test.js:46:34
this is my own library that I am testing, so I am familiar with what is happening. Seems clear that the above error message should at least contain: " 'did not throw with expected message' ". The expected assert module behavior will help me in this regard, but it's not behaving.
Is this a known problem? What am I missing?
The text was updated successfully, but these errors were encountered:
Implementing testing-specific assertions like assert.throws() is regarded by many in core to have been a mistake. We're stuck with it because so much of the ecosystem depends on it. But there is mild language in the docs discouraging people from using assert as a general purpose testing library. You might consider using something like chai instead. Their assert API is like the internal module, but likely contains fewer surprises like this. Good luck.
Uh oh!
There was an error while loading. Please reload this page.
On MacOS 64bit, Node.js version 6.7.0
using the core "assert" module, like so:
the above is fine, no error is thrown because the block does throw an error with a message that matches the regex
however, if I do this, I get something unexpected (I changed the regex):
it will give me this:
this is my own library that I am testing, so I am familiar with what is happening. Seems clear that the above error message should at least contain: " 'did not throw with expected message' ". The expected assert module behavior will help me in this regard, but it's not behaving.
Is this a known problem? What am I missing?
The text was updated successfully, but these errors were encountered: