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
toThrowError() treats an empty string (toThrowError('')) as it would if the value was undefined when it should reject an empty string as it is not equal to the error.
Reproduction
import { expect, test } from 'vitest'
function getFruitStock(type: string): void {
if (type === 'pineapples') {
throw new Error('Pineapples are not in stock')
}
}
test('throws on pineapples', () => {
// undefined error passes
expect(() => getFruitStock('pineapples')).toThrowError()
// error of empty string should fail as it does not represent the error but passes
expect(() => getFruitStock('pineapples')).toThrowError('')
})
Describe the bug
toThrowError()
treats an empty string (toThrowError('')
) as it would if the value was undefined when it should reject an empty string as it is not equal to the error.Reproduction
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: