inferno icon indicating copy to clipboard operation
inferno copied to clipboard

[inferno-test-utils] How to use this lib to change state or props, trigger change/input event/keydown event?

Open ReginaLiang opened this issue 3 years ago • 1 comments

When I use inferno-test-utils lib to test my inferno app, I encounter some problems that need your help. Firstly I rendered a component use renderIntoContainer.

But I have some problems blocks my work.

  1. How to get this rendered instance that I can get the global variables bound component?
  2. How can I change state/props in a test suite so that improving code coverage?
  3. How can I manually trigger input/change events in a test suite when I test the input element?

Look forward to your replying. Thanks.

ReginaLiang avatar Mar 11 '21 02:03 ReginaLiang

Hi,

If you use renderIntoContainer then you need to manually attach the container to DOM to make events work :(

The issue with renderIntoContainer is that if inferno attaches it to the DOM then somebody would need to remove the container from the DOM or it leaks resources.

Maybe you could try to have a look at these tests for some idea how to write to your own:

https://github.com/infernojs/inferno/tree/master/packages/inferno-create-element/tests

Havunen avatar Mar 11 '21 06:03 Havunen