Created
October 5, 2017 01:36
-
-
Save apsicle/c369bbd849697231b15df0c2c31cfc77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
class TestComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
description: 'asdf123' | |
}; | |
} | |
render() { | |
return ( | |
<div> | |
<p>{this.state.description}</p> | |
</div> | |
) | |
} | |
} | |
test('Should have a defined state', () => { | |
const wrapper = shallow(<TestComponent />); | |
console.log(wrapper.state().description); // cannot get property 'description' of undefined | |
console.log(wrapper.state()); // returns undefined | |
expect(wrapper).toMatchSnapshot(); // I get <p>asdf123</p> in here, so state seems to be working? | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment