testing-library / testcafe-testing-library

:ox: Simple and complete custom Selectors for Testcafe that encourage good testing practices.
http://npm.im/@testing-library/testcafe
MIT License
71 stars 15 forks source link

Allow configurable debug print size with DEBUG_PRINT_LIMIT env var #322

Open cdimitroulas opened 2 years ago

cdimitroulas commented 2 years ago

Is your feature request related to a problem? Please describe. Other testing-library libs have the ability to configure the size of the debug output by using the DEBUG_PRINT_LIMIT env variable. This doesn't seem to work with testcafe-testing-library.

Describe the solution you'd like Allow setting DEBUG_PRINT_LIMIT to increase the size of the default debug print when selectors like getByText fail to find an element.

Describe alternatives you've considered N/A

Additional context N/A

benmonro commented 2 years ago

would welcome a PR for this. :)

cdimitroulas commented 2 years ago

Will try to find some time to look into this

cdimitroulas commented 2 years ago

@benmonro I tried to dig into this a bit but wasn't able to make much progress.

I tried to replicate the tests from here as a starting point but I wasn't able to figure out how to capture the error message which includes a printout of the DOM in the test code since that error occurs on the client-side when running with testcafe.

Similarly, the way the DEBUG_PRINT_LIMIT works in testing-library/dom is by looking for process.env.DEBUG_PRINT_LIMIT which makes sense in a Node.js environment but is slightly weirder on the client-side. The only idea I had was to try setting up a window.process.env object on the client-side and pass this env var to the client-side somehow. Do you have any advice on how this could be done nicely with testcafe?