react-input-mask icon indicating copy to clipboard operation
react-input-mask copied to clipboard

Does not work Jest snapshot testing

Open npi3pak opened this issue 5 years ago • 2 comments

Hello, I'm trying to do snapshot testing with Jest and react-test-renderer, but it fails.

I use 3.0.0-alpha.2

code:

import React from 'react';
import renderer from 'react-test-renderer';
import InputMask from 'react-input-mask';

describe("'DateField' component", () => {
  it('should render', () => {
    const tree = renderer
      .create(
        <InputMask mask="99.99.9999">
          <input />
        </InputMask>
      )
      .toJSON();

    expect(tree).toMatchSnapshot();
  });
});

Error:

TypeError: Cannot read property 'addEventListener' of null

       6 |   it('should render', () => {
       7 |     const tree = renderer
    >  8 |       .create(
         |        ^
       9 |         <InputMask
      10 |           // type="text"
      11 |           // alwaysShowMask

npi3pak avatar Jul 15 '20 22:07 npi3pak

Thanks for your PR @npi3pak, in the meantime I've published a fix on npm =>

  • npm install -S @iam4x/react-input-mask@^3.0.0-alpha.3

iam4x avatar Sep 11 '20 09:09 iam4x

Any progress on a fix? This is still an issue and I am getting an error with react-test-renderer and Storybook7!

  TypeError: Cannot read properties of null (reading 'addEventListener')

      at node_modules/react-input-mask/lib/react-input-mask.development.js:219:11
...

mushkin-v avatar Jan 29 '24 16:01 mushkin-v