G
G
GaserV2022-03-07 19:24:20
JavaScript
GaserV, 2022-03-07 19:24:20

How to test this kind of components?

There is this component:

<div className={cn('list', { active: isOpen })}>
      <Visible xs sm md>
        <AdditionalComponent />
      </Visible>
      Hello world!
    </div>


Visible component is used from react-grid-system. First thing that came to mind:
global.innerWidth = 500;
global.dispatchEvent(new Event('resize'));


But is it right to do so?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vItalIyIrtlach, 2022-03-07
@w13vitaliy

These tests are usually Brittle because the jest dom is not the full DOM of the browser, so they need to be approached with extreme care.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question