Component tests not running after trying to installGlobals()
#8424
Unanswered
powerfulech0
asked this question in
Q&A
Replies: 2 comments
-
Do you have a sample repo? Here's how I setup Vitest in my template. https://github.com/kiliman/remix-vite-template/blob/main/docs/setup/vitest.md And here's a sample test: import { createRemixStub } from '@remix-run/testing'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { expect, test } from 'vitest'
import Counter, { action, loader } from './counter'
test('counter increments when clicked', async () => {
const App = createRemixStub([
{
path: '/counter',
Component: Counter,
loader,
action,
},
])
await render(<App initialEntries={['/counter']} />)
const button = await screen.findByRole('button', { name: /count:/i })
expect(button).toHaveTextContent('Count: 0')
await userEvent.click(button)
expect(button).toHaveTextContent('Count: 1')
}) |
Beta Was this translation helpful? Give feedback.
0 replies
-
I created one @kiliman https://github.com/lukasalvarezdev/jest-remix-repro It happens with jest but not with vitest. Thanks for the help! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
New to Remix, was wondering what I am doing wrong in this approach:
I have a test for a component that uses the fetcher in it:
When I run the tests it gives this error back:
Which led me to trying to install the polyfills with
installGlobals
in a Jest setup file:After which I get this error message:
Any ideas what I'm missing here?
Beta Was this translation helpful? Give feedback.
All reactions