jest-cucumber icon indicating copy to clipboard operation
jest-cucumber copied to clipboard

Can't test the front-end using testing library

Open IvaanTorres opened this issue 2 years ago • 2 comments

I've been configuring jest-cucumber to set it up in my project (NextJS), however, I realized that jest-cucumber just work if I set up Jest with -> testEnvironment="Node". It works if I just test mathematical functions, however, in case I try to render some React components, it just crashes. I'm wondering if jest-cucumber has been developed for server side and not for the front-end.

Here the output and my setup: Jest config: config

jest-cucumber setup file (without it, the test fails as well): setup file

The test example using React Testing Library: test

The output of the test: output

<> - I installed all the main packages such as ts-jest, etc to transform the main files. <> - I'm using some testing tools besides jest-cucumber such as Jest and React Testing Library.

Thanks for the help

IvaanTorres avatar Aug 10 '22 16:08 IvaanTorres

** Update ** You can use the package called "jsdom-global" so you can render a dom in nodejs You just have to require it in every test since Jest has to be configured to use "Node" as testEnvironment

IvaanTorres avatar Aug 10 '22 19:08 IvaanTorres

** Update ** You can use the package called "jsdom-global" so you can render a dom in nodejs You just have to require it in every test since Jest has to be configured to use "Node" as testEnvironment

Do you have an example? I've tried to require it but it's still not working for me

alecat88 avatar Jun 28 '23 14:06 alecat88

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 29 '24 02:03 github-actions[bot]

This issue is closed because there has been no recent activity.

github-actions[bot] avatar Apr 05 '24 02:04 github-actions[bot]