I'm trying to set up a snapshot for a small react component but I keep getting the following error
TypeError: val.getMockName is not a function
it('renders correctly', () => {
const wrapper = renderer.create(<Partners content={content} />).toJSON()
>
expect(wrapper).toMatchSnapshot()
^
})
This is my test file:
import React from 'react'
import renderer from 'react-test-renderer'
import Partners from './index'
import { content } from '../../content/anywhere-everywhere'
jest.mock('react-lazy-load', () => 'LazyLoad')
it('renders correctly', () => {
const wrapper = renderer.create(<Partners content={content} />).toJSON()
expect(wrapper).toMatchSnapshot()
})
This is the component
import React from 'react'
import LazyLoad from 'react-lazy-load'
const Partners = ({ content }) => (
<section className="partners">
<h3>{content.partnersCopy}</h3>
<div className="partners__slider">
{content.partnerLogos.map((partnerLogo, index) => (
<LazyLoad key={index}>
<img src={partnerLogo.src} alt={partnerLogo.alt} />
</LazyLoad>
))}
</div>
</section>
)
export default Partners
and i set up a mocks folder
'use strict'
const LazyLoad = jest.genMockFromModule('react-lazy-load')
export default LazyLoad