NewLabRequest.test.tsx is flaky

Author: DrewGregoryCreated Apr 18, 2021Updated Nov 19, 2021
Labels🐛bug

Please read this entire template before posting any issue. If you ignore these instructions and post an issue here that does not follow the instructions, your issue might be closed, locked, and assigned the missing discussion label.

Bug Report

The NewLabRequest form layout › should clear visit when patient is changed test spuriously times out. In addition, on save › should save the lab request and navigate to "/labs/:id" spuriously has visitsInput assume a display value of [""] instead of the desired string. The test output is included below.

To Reproduce

Steps to reproduce the behavior:

Run npm run test:ci src/__tests__/labs/requests/NewLabRequest.test.tsx several times until you encounter the error.

Paste your code here:

javascript
New Lab Request › on save › should save the lab request and navigate to "/labs/:id"

    expect(element).toHaveDisplayValue()

    Expected element to have display value:
      visit_type at 2021-04-18 01:58 PM
    Received:
      [""]

      157 |         }),
      158 |       )
    > 159 |       expect(visitsInput).toHaveDisplayValue(
          |                           ^
      160 |         `${expectedVisits[0].type} at ${format(
      161 |           new Date(expectedVisits[0].startDateTime),
      162 |           'yyyy-MM-dd hh:mm a',

Expected behavior

All the tests should pass.

Your Environment

  • node version: v12.18.4
  • os: Mac

Source: HospitalRun/hospitalrun-frontend