the code expect(undefined).not.toBeUndefined
it pass the test.
Dose it means undefined !== undefined ????
and I found any test with toBeUndefined, it will pass
like this expect(1).toBeUndefined
the full test code
test('1: undefined is not be undefined?', () => {
expect(undefined).not.toBeUndefined
})
test('2: undefined is not be undefined?', () => {
expect(undefined).not.toBe(undefined)
})
test('3: 1 is be the undefined?', () => {
expect(1).toBeUndefined
})
the result
FAIL test/undefined.test.js
✓ 1: undefined is not be undefined?
✕ 2: undefined is not be undefined? (1ms)
✓ 3: 1 is be the undefined?
● 2: undefined is not be undefined?
expect(received).not.toBe(expected) // Object.is equality
Expected: not undefined
6 |
7 | test('2: undefined is not be undefined?', () => {
> 8 | expect(undefined).not.toBe(undefined)
| ^
9 | })
10 |
11 |
at Object.<anonymous>.test **(test/undefined.test.js:8:25)**
## Expected behavior
toBeUndefined should alias toBe(undefined)
I found the code expect(undefined).toBeDefined will pass the test also.
You need to call it: expect(undefined).toBeDefined(), it's a function, not a property/getter
You need to call it:
expect(undefined).toBeDefined(), it's a function, not a property/getter
@thymikee thanks,
I am sorry to submit this issue,
and I should ready the docs carefully.
Happens! Have fun testing :)
Most helpful comment
You need to call it:
expect(undefined).toBeDefined(), it's a function, not a property/getter