-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
bugcurrent functionality does not work as desiredcurrent functionality does not work as desiredscope:assertions
Description
Description
t.throws() will pass if provided the arguments false, undefined and null. I would expect these tests to fail since, according to the docs:
errorcan be an error constructor, error message, regex matched against the error message, or validation function.
For my particular use case, I wanted to test that the error thrown was an instance of a custom error. However, the custom error was not implemented and so undefined was passed into t.throws(). The test still succeeded, which is not the desired behavior.
Test Source
The following tests will incorrectly pass
test('false', t => {
t.throws(() => { throw new Error('foo') }, false)
})
test('undefined', t => {
t.throws(() => { throw new Error('foo') }, undefined)
})
test('null', t => {
t.throws(() => { throw new Error('foo') }, null)
})Error Message & Stack Trace
â–¶ node_modules/.bin/ava -v
✔ false
✔ undefined
✔ null
3 tests passed
Config
Using vanilla ava—no config
Command-Line Arguments
ava -v
Environment
â–¶ node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
Node.js v8.9.4
linux 4.13.0-32-generic
â–¶ node_modules/.bin/ava --version
0.25.0
â–¶ npm --version
5.6.0
Metadata
Metadata
Assignees
Labels
bugcurrent functionality does not work as desiredcurrent functionality does not work as desiredscope:assertions