expect.anything() fails on null value #7626
-
Hi, I have following test: import { describe, it, expect } from 'vitest';
describe('expect.anything() matcher', () => {
it('should allow null values', () => {
const obj = {
id: 1,
sort: null,
title: 'Where',
description: 'description'
};
expect(obj).toEqual(expect.objectContaining({
id: expect.any(Number),
sort: expect.anything(),
title: expect.any(String),
description: expect.any(String)
}));
});
}); It fails because of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The documentation is wrong, |
Beta Was this translation helpful? Give feedback.
I think there is now
expect.toBeOneOf([null, 'another value'])