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

[Bug?]: Mantine components break web tests #10044

Open
1 task
will-ks opened this issue Feb 20, 2024 · 2 comments
Open
1 task

[Bug?]: Mantine components break web tests #10044

will-ks opened this issue Feb 20, 2024 · 2 comments
Labels
bug/needs-info More information is needed for reproduction help wanted p3 Low priority. The Core team will not prioritize this for now topic/testing

Comments

@will-ks
Copy link
Contributor

will-ks commented Feb 20, 2024

What's not working?

After setting up mantine components with yarn rw setup ui mantine and using any mantine component, the tests will fail due to:

Error: @mantine/core: MantineProvider was not found in component tree, make sure you have it in your app

The fix for this would be to add MantineProvider to the react-testing-library wrappers (ie. here https://github.com/redwoodjs/redwood/blob/main/packages/testing/src/web/customRender.tsx#L20).

Ideally the setup command would handle this, but if not possible, maybe the docs could be updated to describe how to get around this yourself?

I have done the following to work around the issue:

  • Create a file with contents:
import { MantineProvider } from '@mantine/core'
import type { RenderOptions } from '@redwoodjs/testing/web'
import { MockProviders, render } from '@redwoodjs/testing/web'
import type { ReactElement } from 'react'

const customRender = (ui: ReactElement, options?: RenderOptions) =>
  render(ui, {
    wrapper: (props) => (
      <MantineProvider>
        <MockProviders {...props} />
      </MantineProvider>
    ),
    ...options,
  })

export { customRender as render }
  • Update all web test files to import render from this file instead of from @redwoodjs/testing/web

How do we reproduce the bug?

  • yarn rw setup ui mantine
  • add any mantine component to a web component
  • run yarn rw test web

What's your environment? (If it applies)

No response

Are you interested in working on this?

  • I'm interested in working on this
@will-ks will-ks added the bug/needs-info More information is needed for reproduction label Feb 20, 2024
@KrisCoulson
Copy link
Contributor

Thanks for the bringing this to our attention @will-ks. I'll make sure to relay to the team to get their thoughts.

@Tobbe Tobbe added help wanted p3 Low priority. The Core team will not prioritize this for now labels Mar 1, 2024
@Tobbe
Copy link
Member

Tobbe commented Mar 1, 2024

Thanks for your well written issue report @will-ks
The team prioritizes React Server Components right now, and won't have time to look into this for a few weeks/months.

If someone from the community submitted a PR I or someone else will review it, but unfortunately that's all I can commit anyone to right now :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction help wanted p3 Low priority. The Core team will not prioritize this for now topic/testing
Projects
None yet
Development

No branches or pull requests

3 participants