Skip to main content

expect.oneOf(values)

An asymmetric matcher that checks if the received value is one of the expected values, using deep equality.

it("is one of the expected values", () => {
const values = {
number: 1,
string: "hello",
boolean: true,
};
expect(values).toEqual({
number: expect.oneOf([1, 2]),
string: expect.oneOf(["hello", "world"]),
boolean: expect.oneOf([true, false]),
});
});