You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{render,screen}from'@testing-library/react';import{Element}from'./element.test';describe('renders the form correctly',()=>{it('test to show form',async()=>{render(<Element/>);//await waitFor(() => {expect(screen.getByRole('textbox',{name: 'firstName'})).toBeInTheDocument();//});});});
Run my tests normally with the configuration above and it fails.
What happened:
when I run my tests, the error that appears is this one:
RangeError: Invalid string length
at printObjectProperties (node_modules/pretty-format/build/collections.js:174:47)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at node_modules/@testing-library/dom/dist/DOMElementFilter.js:39:79
at Array.map (<anonymous>)
at printChildren (node_modules/@testing-library/dom/dist/DOMElementFilter.js:38:89)
at Object.serialize (node_modules/@testing-library/dom/dist/DOMElementFilter.js:115:75)
at printPlugin (node_modules/pretty-format/build/index.js:330:16)
at printer (node_modules/pretty-format/build/index.js:379:12)
at node_modules/@testing-library/dom/dist/DOMElementFilter.js:39:79
at Array.map (<anonymous>)
at printChildren (node_modules/@testing-library/dom/dist/DOMElementFilter.js:38:89)
at Object.serialize (node_modules/@testing-library/dom/dist/DOMElementFilter.js:115:75)
at printPlugin (node_modules/pretty-format/build/index.js:330:16)
at printer (node_modules/pretty-format/build/index.js:379:12)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at node_modules/@testing-library/dom/dist/DOMElementFilter.js:39:79
at Array.map (<anonymous>)
at printChildren (node_modules/@testing-library/dom/dist/DOMElementFilter.js:38:89)
at Object.serialize (node_modules/@testing-library/dom/dist/DOMElementFilter.js:115:75)
at printPlugin (node_modules/pretty-format/build/index.js:330:16)
at printer (node_modules/pretty-format/build/index.js:379:12)
at node_modules/@testing-library/dom/dist/DOMElementFilter.js:39:79
at Array.map (<anonymous>)
at printChildren (node_modules/@testing-library/dom/dist/DOMElementFilter.js:38:89)
at Object.serialize (node_modules/@testing-library/dom/dist/DOMElementFilter.js:115:75)
at printPlugin (node_modules/pretty-format/build/index.js:330:16)
at printer (node_modules/pretty-format/build/index.js:379:12)
at node_modules/@testing-library/dom/dist/DOMElementFilter.js:39:79
at Array.map (<anonymous>)
at printChildren (node_modules/@testing-library/dom/dist/DOMElementFilter.js:38:89)
at Object.serialize (node_modules/@testing-library/dom/dist/DOMElementFilter.js:115:75)
at printPlugin (node_modules/pretty-format/build/index.js:330:16)
at printer (node_modules/pretty-format/build/index.js:379:12)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at node_modules/@testing-library/dom/dist/DOMElementFilter.js:39:79
at Array.map (<anonymous>)
at printChildren (node_modules/@testing-library/dom/dist/DOMElementFilter.js:38:89)
at Object.serialize (node_modules/@testing-library/dom/dist/DOMElementFilter.js:115:75)
at printPlugin (node_modules/pretty-format/build/index.js:330:16)
at printer (node_modules/pretty-format/build/index.js:379:12)
at node_modules/@testing-library/dom/dist/DOMElementFilter.js:39:79
at Array.map (<anonymous>)
at printChildren (node_modules/@testing-library/dom/dist/DOMElementFilter.js:38:89)
at Object.serialize (node_modules/@testing-library/dom/dist/DOMElementFilter.js:115:75)
at printPlugin (node_modules/pretty-format/build/index.js:330:16)
at printer (node_modules/pretty-format/build/index.js:379:12)
at node_modules/@testing-library/dom/dist/DOMElementFilter.js:39:79
at Array.map (<anonymous>)
at printChildren (node_modules/@testing-library/dom/dist/DOMElementFilter.js:38:89)
at Object.serialize (node_modules/@testing-library/dom/dist/DOMElementFilter.js:115:75)
at printPlugin (node_modules/pretty-format/build/index.js:330:16)
at printer (node_modules/pretty-format/build/index.js:379:12)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
at printComplexValue (node_modules/pretty-format/build/index.js:310:48)
at printer (node_modules/pretty-format/build/index.js:393:10)
at printObjectProperties (node_modules/pretty-format/build/collections.js:173:21)
and if I remove the transform in my .swcrc file get this error:
ReferenceError: React is not defined
Also, I have tried different solutions found on the internet like add this in jest.setup.ts file:
importReactfrom'react';global.React=React;
But I get the first error mentioned above.
Problem description:
As I mention Above it occurs when I tried to run a normal test with testing library, the other ones without React code works fine.
The text was updated successfully, but these errors were encountered:
I encountered the same RangeError when testing components that use ShadowDOM - seems like something is trying to serialize a circular structure that creates a massive string. Sometimes this causes tests to be very slow and others it only causes the prettyDOM call used for debugging failures to print an error instead of the DOM.
Hi @kappys1, thanks for opening this one.
Since the code examples doesn't contain everything we need, to further investigate it, we'll need a minimal reproduction using github/codesandbox.
@testing-library/react
version: 14.0.0Testing Framework and version:
Other relevant dependencies:
Relevant code or config:
Example test
jest.setup.ts
jest.config.ts
What you did:
Run my tests normally with the configuration above and it fails.
What happened:
when I run my tests, the error that appears is this one:
and if I remove the transform in my
.swcrc
file get this error:Also, I have tried different solutions found on the internet like add this in
jest.setup.ts
file:But I get the first error mentioned above.
Problem description:
As I mention Above it occurs when I tried to run a normal test with testing library, the other ones without React code works fine.
The text was updated successfully, but these errors were encountered: