bun
bun copied to clipboard
`toHaveProperty` should always throw
What version of Bun is running?
No response
What platform is your computer?
No response
What steps can reproduce the bug?
This is an inaccuracy in comparison to jest and vitest.
Both these lines should throw, bun doesnt throw on the .not because it inverts the test condition.
expect(null).not.toHaveProperty("length");
expect(null).toHaveProperty("length");
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
I think it should always throw when the expect value is not an object.
I think it should always throw when the
expectvalue is not an object.
expect('string').toHaveProperty('length') should be true though.
Jest throws when the passed arg is null or undefined. See code here.
null is indeed an object so I'm leaning towards this is indeed expected behavior. will followup after I can test in other libraries