Skip to content

[BUG] Can't mock overmind for jest snapshots #594

@crimson-med

Description

@crimson-med

We are currently using overmind on a project and have added Jest snapshots for testing the coverage and the components.

import { render } from '@testing-library/react'
import Home from './page'

it(`renders correctly`, () => {
  const { container } = render(<Home />)
  expect(container).toMatchSnapshot()
})

Withing the home page a few sub components are rendered which use the useAppState function and this creates some issues within the test:

The Overmind hook could not find an Overmind instance on the context of React. Please make sure you use the Provider component at the top of your application and expose the Overmind instance there. Please read more in the React guide on the website

const { myState } = useAppState().api

How to make overmind compatible with the following types of tests.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions