Questions tagged [enzyme-to-snapshot]
15 questions
5
votes
0 answers
Jest suite doesn't output color for the snapshot diff
I just noticed on a project I'm working on that the snapshot output is not piping through colours to the terminal. The Jest framework in general does have colours. So I'm pretty confused:
What it should look like
This is the list of relevant…

Ashley Coolman
- 11,095
- 5
- 59
- 81
2
votes
0 answers
Testing react-hook-form's Controller API using enzyme / Jest
Is there a way to test a component that uses react-hook-form's Controller API using Jest/enzyme?
Kindly take a look at this code sandbox to see what my component looks like
I did try mocking Controller using the below for a snapshot…

Orelongz
- 41
- 1
- 5
2
votes
2 answers
shallowWrapper is empty, testing snapshot Jest/Enzyme?
I don't know why i get empty shallowWrapper object when i run snapshot test, i am using Jest and Enzyme:
What i get in App.test.js.snap file:
// Jest Snapshot v1, "goo.gl/fbAQLP"
exports[`renders App component 1`] = `ShallowWrapper {}`;
my…

Saher Elgendy
- 1,519
- 4
- 16
- 27
2
votes
2 answers
TypeError: Cannot read property 'PlatformLocalStorage' of undefined
I am running jest test on react-native and getting this following errors
Test suite failed to run
TypeError: Cannot read property 'PlatformLocalStorage' of undefined
2 | import thunk from 'redux-thunk';
3 | import { persistStore,…

Aftab Aslam
- 25
- 4
2
votes
0 answers
styled-components - enzyme shallow snapshots
I am trying to find the solution how to avoid whole theme object in Jest snapshot.
I got, for Example, this simple test.
test("render", () => {
const wrapper = shallow( );
…

Grund
- 309
- 1
- 2
- 12
2
votes
1 answer
Enzyme renders wrapped component rather than base component
I am snapshot testing my React app with Jest and Enzyme. I am trying to export a testable version of my component that is not wrapped in a higher order component.
I then want to export the wrapped component so my app can use it, and also a testable…

Chris
- 7,830
- 6
- 38
- 72
2
votes
1 answer
Test React component (Jest & Enzyme) that renders differently after Ajax
How do you test a component (say in this case) if it renders fully but only after completes, which is after a successful Ajax call?
I am using Jest and Enzyme. With Enzyme, however, the snapshot would be of Person with the…

user1322092
- 4,020
- 7
- 35
- 52
1
vote
0 answers
Enzyme shallow styled component output snapshot that does not have className
I have a simple test with enzyme to shallow a styled.div`` with some css in it. But the snapshot does not className in it
This is the snapshot:
exports[` should render correctly 1`] = `
This is
…

Minh Nguyen
- 81
- 4
1
vote
1 answer
enzyme-to-snapshot render object as JSON
Why render object JSON in snapshot?
For an component
const MyComp =
,
I test as
const wrapper = mount(MyComp…

ridermansb
- 10,779
- 24
- 115
- 226
0
votes
1 answer
ReactJS Enzyme Jest issue Could not find "store" in the context of "Connect(component)" even when wrapped inside provider getting suggestion to wrap
Invariant Violation: Could not find "store" in the context of "Connect(Component)". Either wrap the root component in a , or pass a custom React context provider to and the corresponding React context consumer to Connect(Component) in connect…

Varsha Tiwari
- 29
- 3
0
votes
1 answer
How to test React component with children using jest and enzyme?
Component to be tested. this.props.children have child components of example.js
class Example extends component {
constructor(){
super(props);
this.state={};
}
render() {
{this.props.children}
}
}
test…
Akshay Gireesh
- 97
- 2
- 10
0
votes
1 answer
Enzyme with React -17.0.1 - Method “text” is meant to be run on 1 node. 0 found instead
I am using react-17.0.1 with enzyme 3.3.0 and @wojtekmaj/enzyme-adapter-react-17, so I am getting a lot of error in tests after migrating to react 17. I have a test like this:
describe('JournalNotesListView', () => {
let wrapper;
beforeEach(()…

suvodipMondal
- 656
- 10
- 27
0
votes
1 answer
React Test TypeError: Cannot read property 'map' of undefined
I'm trying to write a test to a component that uses the redux state as props and I'm getting the following error.
Should render expense list with expenses
TypeError: Cannot read property 'map' of undefined
at ExpenseList…

Clish
- 38
- 5
0
votes
1 answer
Snapshot with jest and enzyme is written inside the test file and not in a separate .snap file
I'm new to react's testing and I created a simple test for checkbox:
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import { Checkbox } from…

Aharon Ohayon
- 1,171
- 1
- 17
- 20
0
votes
0 answers
Exclude certain modules in deep rendering
I'm using jest snapshot comparison in combination with enzyme mount rendering. Is it possible to define a list of components which will be excluded from deep rendering?

papadi
- 985
- 2
- 9
- 22