samedi 22 juin 2019

React snapshot testing, jest/enzyme, getting empty ShallowWrapper

I have a basic snapshot test, but its giving me an empty ShallowWrapper which allows tests to pass even when I change the component.

This is has been asked before but I dont consider downgrading to previous version of Jest to be the optimal solution Jest/Enzyme ShallowWrapper is empty when creating Snapshot

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import Enzyme, { shallow, render, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

Enzyme.configure({ adapter: new Adapter() })

it('renders correctly', () => {
  const wrapper = shallow(<App />)
  console.log(wrapper.debug());
  expect(wrapper).toMatchSnapshot();
});

App.test.js.snap

exports[`renders correctly 1`] = `ShallowWrapper {}`;

Aucun commentaire:

Enregistrer un commentaire