scottrippey / next-router-mock

Mock implementation of the Next.js Router
MIT License
400 stars 38 forks source link

docs(README): replace require with jest.requireActual #90

Closed jackhkmatthews closed 1 year ago

jackhkmatthews commented 1 year ago

Use jest.requireActual to avoid using a CommonJS require statement .

In my TS project, ESLint was shouting at me when using require: https://typescript-eslint.io/rules/no-var-requires

Using requireActual resolved this:

jest.mock("next/router", () => jest.requireActual<MemoryRouter>("next-router-mock"));
scottrippey commented 1 year ago

Thank you! Worked great on an example app.