Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use vitest with next-view-transitions #23

Open
devpedrodiass opened this issue Jun 13, 2024 · 2 comments
Open

How can I use vitest with next-view-transitions #23

devpedrodiass opened this issue Jun 13, 2024 · 2 comments

Comments

@devpedrodiass
Copy link

I setup Vitest on my project, but I'm with this error.

Can someone help me?

image

@andrei-hernandez
Copy link

andrei-hernandez commented Sep 4, 2024

Did you find a solution/workaround for this? I'm having the same issue :x
Even in Jest does not work

@jonathan-ingram
Copy link

I had similar problems using Jest (along with additional errors regarding Jest encountering an unexpected token etc). 🤔

I assume this is happening because Jest can't see any links inside our components/pages (because they're now being handled by next-view-transitions rather than next/link) therefore, I was able to fix this by mocking the rendering of those links instead....

jest.mock("next-view-transitions", () => ({
  Link: jest.fn(({ children, ...rest }) => <a {...rest}>{children}</a>),
}));

This allows the link to be rendered (in the eyes of Jest) with both ...rest and children ensuring anything else associated with your links is not lost in the process.

Happy to hear alternative methods if someone suggests something more elegant, thanks! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants