Skip to content

[Docs]: Uprade from 29 to 30 jest.mock("./path/to/module") is case-sensitive now #15847

@htho

Description

@htho

Page(s)

https://jestjs.io/docs/upgrading-to-jest30

Description

Hi,

I am upgrading from v29 to v30, and this took me a while to figure out:

jest.mock("./path/to/module") is case-sensitive now.

jest.mock("../src/THEANSWER"); // <- works in v29 but fails in v30
// jest.mock("../src/theAnswer"); // <- works in v30
import { getTheAnswer } from "../src/theAnswer";

describe("getTheAnswer", () => {
    it("is called", () => {
        expect(getTheAnswer).not.toHaveBeenCalled(); // <- fails in v30: `Matcher error: received value must be a mock or spy function`
        getTheAnswer();
        expect(getTheAnswer).toHaveBeenCalled();
    });
});

I can imagine that this happens because of the update to glob v10 but when I read the documentation I did not expect jest.mock() to be affected.

Maybe we should add this information to the upgrade document?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions