JEST Snapshot Testing always creates a unique identifier for the ID and htmlFor
See original GitHub issueHi Guys
I’m using redux-form and Jest snapshot testing in our application. Unfortunately there is a problem regarding the snapshot creation. Every time the snapshot is created the ID and the htmlFor attribute on the form field changed to a different unique ID.
Am i doing something wrong, or is that a known problem?
I’m running the following test for a Login component, that consists of two redux-form fields.
`describe('Login Component', () = {
it('renders correctly', () = {
const props = {
onLogin: jest.fn(),
};
const locale = 'de';
const store = mockStore({
i18n: {
locale,
locales,
},
form: {},
});
const tree = renderer.create(
<Provider store={store}>
<I18n locales={locales} locale={locale}>
<ThemeProvider theme={theme}>
<Login {...props} />
</ThemeProvider>
</I18n>
</Provider>
).toJSON();
expect(tree).toMatchSnapshot();
});
});`
<Field component={TextInputWrapper} className={this.props.theme.textInput} name="email" type="email" caption={this.props.t('E-Mail')}/>
After running the test and updating the snapshot it fails because of the following problem:
There is someone on stackoverflow, which has the same problem. http://stackoverflow.com/questions/41167981/how-to-stop-redux-form-or-react-from-changing-htmlfor-and-id-when-creating-jest
Can someone provide some answers regarding this problem?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top GitHub Comments
no @anubhavDaffodil I also did the same by providing a constant ID to each Field. I think thats a reasonable way to do it 😃
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.