Skip to content

Instantly share code, notes, and snippets.

@SPavelV
Created November 13, 2019 09:08
Show Gist options
  • Select an option

  • Save SPavelV/068fd83a3c01d764f97c703066e0c834 to your computer and use it in GitHub Desktop.

Select an option

Save SPavelV/068fd83a3c01d764f97c703066e0c834 to your computer and use it in GitHub Desktop.
Enzyme instance() method should be able to carry type of wrapped class
class MyComponentWithMethods extends React.Component<{}, {}> {
someMethod() {
return 'some string';
}
}
test('instance type by providing component type explicitly works', () => {
const wrapper = shallow<MyComponentWithMethods>(<MyComponentWithMethods />);
expect(wrapper.instance().someMethod()).toBe('some string');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment