marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
810 stars 56 forks source link

How to compare mock to an object with jest #125

Open kasium opened 11 months ago

kasium commented 11 months ago

I want to compare a mock to an object in jest but it won't work

        interface Foo {
            a: string;
            b: number;
        }

        const foo = mock<Foo>();
        foo.a = "bar";
        expect(foo).toStrictEqual({ a: "bar" });

Output:

    expect(received).toStrictEqual(expected) // deep equality

    Expected: {"a": "bar"}
    Received: undefined

Do you know why this is undefined?

zaid-hopstack commented 10 months ago

@kasium I have the same question. Did you end up finding an answer for this?

kasium commented 10 months ago

@zaid-hopstack nope