Expect Any And Anything And Array Containing
all.test.js
// expect.anything() => Anything But Undefined + Null
test("Expect Anything", () => {
let x = "A";
expect("Osama").toEqual(expect.anything());
expect(1).toEqual(expect.anything());
expect([1, 2, 3, 4]).toEqual(expect.anything());
expect(x).toEqual(expect.anything());
});
// expect.any(Constructor)
test("Expect Any Constructor", () => {
expect("Osama").toEqual(expect.any(String));
});
// expect.arrayContaining(array)
test("Expect Array To Be Found In The Main Array", () => {
const myArray = [1, 2, 3, 4, 5, 6];
expect(myArray).toEqual(expect.arrayContaining([5, 3, 4, 6]));
});