BrainArchitect
BrainArchitect

Reputation: 561

How to Jest.mock redux-form's Field

My react class components looks like this:

import { Field, reduxForm, propTypes } from 'redux-form';

class DepositAmountInput extends Component {
  render() {
    return (
      <View>
        <Field
          component={NumberInputField}
          props={{
            onChange: this.handleInput,
            onBlur: this.handleOnBlur
          }}
        />
      </View>
    );
  }
}
export default DepositAmountInput

In my Jest test for this component, how can I mock the Field component of redux-form? I am looking for something like this:

.mock('redux-form/lib/Field', () => 'Field');

Thanks!

Upvotes: 2

Views: 1665

Answers (1)

Hyph&#230;ne Ohmen
Hyph&#230;ne Ohmen

Reputation: 139

this is the code which runs perfectly well on my test ( see picture below ) jest.mock('redux-form/lib/Field', () => 'field'); (same as the one you were expecting then. )

on my pacakage.json : { "redux-form": "^7.0.3", "jest": "^20.0.4", } screenshot

Upvotes: 1

Related Questions