Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: DatrePicker-test.js react.lazy test should use waitFor() #15701

Closed
2 tasks done
jt-helsinki opened this issue Feb 6, 2024 · 0 comments · Fixed by #15702
Closed
2 tasks done

[Bug]: DatrePicker-test.js react.lazy test should use waitFor() #15701

jt-helsinki opened this issue Feb 6, 2024 · 0 comments · Fixed by #15702

Comments

@jt-helsinki
Copy link
Contributor

Package

@carbon/react

Browser

Chrome

Package version

v11.49.0

React version

18.2.0

Description

The test "should initialize a calendar when using react.lazy" would be more robust if it used waitFor().

For example:

render(
        <React.Suspense fallback="Loading">
          <LazyDatePicker datePickerType="single">
            <LazyDatePickerInput
              placeholder="mm/dd/yyyy"
              labelText="Date Picker label"
              id="date-picker-simple"
            />
          </LazyDatePicker>
        </React.Suspense>
      );

      const labeledElement = await screen.findByLabelText('Date Picker label');
      expect(labeledElement).toBeInTheDocument();

becomes

const labeledElement = await waitFor(() => screen.findByLabelText('Date Picker label'), { timeout: 10000 });

Reproduction/example

n/a

Steps to reproduce

Not consistent. Run the tests in CI mode and the error intermittently.

Suggested Severity

None

Application/PAL

No response

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant