Skip to content

Instantly share code, notes, and snippets.

@javidjamae
Created September 27, 2017 08:05
Show Gist options
  • Save javidjamae/3028d5bd1fd749f375efa96ea434583c to your computer and use it in GitHub Desktop.
Save javidjamae/3028d5bd1fd749f375efa96ea434583c to your computer and use it in GitHub Desktop.
Mocking out a TextInput with jest
jest.mock( 'TextInput', () => {
const RealComponent = require.requireActual( 'TextInput' )
const React = require( 'React' )
class TextInput extends React.Component {
render() {
delete this.props.autoFocus
return React.createElement( 'TextInput', this.props, this.props.children )
}
}
TextInput.propTypes = RealComponent.propTypes
return TextInput
} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment