next-router-mock icon indicating copy to clipboard operation
next-router-mock copied to clipboard

Consider the skipTrailingSlashRedirect config

Open patik opened this issue 2 years ago • 1 comments

In my next.config.js I have skipTrailingSlashRedirect: true, i.e. the URLs should retain their trailing slash. next-router-mock however seems to trim the trailing slash from all URLs.

This fails:

// Component
router.push('/foo/')

// Test
const spy = jest.fn()
render(<MemoryRouterProvider onPush={spy}><Component /></MemoryRouterProvider)
expect(spy).toHaveBeenCalledWith('/foo/') // Instead, it is called with /foo

I'm able to fix this by patching the package (I changed normalizeTrailingSlash()), but it would be cool to have first class support.

patik avatar Jul 21 '23 15:07 patik

This sounds like a good idea, I will try to add support. PRs are welcome though, if you have a fix or some unit tests!

scottrippey avatar Jul 27 '23 19:07 scottrippey