next-router-mock
next-router-mock copied to clipboard
Mock implementation of the Next.js Router
Hello! I've happened to runtime error with the testing readme. ```typescript import singletonRouter from 'next/router'; import NextLink from 'next/link'; import { render, fireEvent, screen, waitFor } from '@testing-library/react'; import mockRouter...
Hello! I've noticed that after upgrade to newest version of Next 12.2.0 (released 3 days ago) there is an issue with tests utilising Next Link. ```js import Link from "next/link"...
Hello! First of all thanks for awesome package, @scottrippey! I try to mock next-router with storybook. Is it real to mock default Router as we do it for useRouter? For...
## Introduction This PR proposes to support `history` in anticipation of `router.back()` support. A picture of future support is envisioned ([like this code](https://github.com/ergofriend/next-router-mock/pull/1/files)). As described in [the React Router testing...
Next 14.1 introduced shallow routing to the App Router via `window.history.pushState/replaceState` (if you only change query string params). The Next App Router watches these calls and updates its internal state...
I know there's a `createDynamicrouterParser` but it seems like this is only intended to be used in Jest. Is there something equivalent for storybook?
This PR adds support for Next 13's new App Router. It supplies functional mocks for the hooks in `next/navigation`. # TODO - [x] Implement `useRouter, usePathname, useParams, useSearchParams` hooks -...
- Next 14.0.1 - Node 18.18.1 - next-router-mock 0.9.10 ``` Module not found: Error: Can't resolve 'next/dist/shared/lib/router-context' in './node_modules/next-router-mock/dist/MemoryRouterProvider' ``` Perhaps `next/dist/shared/lib/router-context.shared-runtime` is the expected path.
I had to create a patch for this type definition that tries to import from Next ```diff diff --git a/node_modules/next-router-mock/dist/MemoryRouterProvider/MemoryRouterProvider.d.ts b/node_modules/next-router-mock/dist/MemoryRouterProvider/MemoryRouterProvider.d.ts index 0318cb2..7d751b1 100644 --- a/node_modules/next-router-mock/dist/MemoryRouterProvider/MemoryRouterProvider.d.ts +++ b/node_modules/next-router-mock/dist/MemoryRouterProvider/MemoryRouterProvider.d.ts @@ -1,7...
I'm trying to text links with this package and I am getting inconsistent behavior. I defined a custom render as follows: ```typescript const mockPath = "/streaming"; const mockItem = {...