Asserts that an object
contain the provided value.
This method is deep and will look through child properties to find the expected value.
The input value must be an object.
method
Asserts that an object
contain the provided value.
This method is deep and will look through child properties to find the expected value.
The input value must be an object.
the expected value
const shallow = { hello: "world" };
const deep = { message: shallow };
const deepArray = { message: [shallow] };
const o = { a: "foo", b: [1, "hello", true], c: "baz" };
expect(shallow).toContainValue("world");
expect({ foo: false }).toContainValue(false);
expect(deep).toContainValue({ hello: "world" });
expect(deepArray).toContainValue([{ hello: "world" }]);
expect(o).toContainValue("foo", "barr");
expect(o).toContainValue([1, "hello", true]);
expect(o).not.toContainValue("qux");
// NOT
expect(shallow).not.toContainValue("foo");
expect(deep).not.toContainValue({ foo: "bar" });
expect(deepArray).not.toContainValue([{ foo: "bar" }]);