testing-library / dom-testing-library

🐙 Simple and complete DOM testing utilities that encourage good testing practices.
https://testing-library.com/dom
MIT License
3.26k stars 466 forks source link

fix: safer read of DEBUG_PRINT_LIMIT #1329

Closed sieem closed 1 month ago

sieem commented 1 month ago

What:

We encountered some issues on our CI. We use Azure DevOps with this image: using docker/cypress/browsers:node-20.14.0-chrome-126.0.6478.114-1-ff-127.0.1-edge-126.0.2592.61-1. This was the log produces when a test failed (for a different reason):

  2) (Site Management) Manage capacity
       Permissions
         Should show the page when user has correct permissions:
     AssertionError: Timed out retrying after 4000ms: Cannot read properties of undefined (reading 'DEBUG_PRINT_LIMIT')
      at Context.eval (webpack:///./src/ui/support/page-permissions.helper.ts:25:0)

Apparently process was defined, while process.env was not. I don't see the harm to do this extra check.

Why: To have proper error logging when a test fails.

How: I first used patch-package to patch this library on our codebase with the same change. This unblocked our ci and gave us proper logging of this failing test.

I ran the tests after my changes on this repo and no tests were failing.

Checklist:

codesandbox-ci[bot] commented 1 month ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0171d619ec151e48cd29d65779967bfcef78c617:

Sandbox Source
react-testing-library-examples Configuration
MatanBobi commented 1 month ago

@all-contributors please add @sieem for code :)

allcontributors[bot] commented 1 month ago

@MatanBobi

I've put up a pull request to add @sieem! :tada: