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

CI Test Failure: Unable to find element by title in TaxYear component test #1980

Closed
MaxGhenis opened this issue Aug 18, 2024 · 0 comments · Fixed by #1979
Closed

CI Test Failure: Unable to find element by title in TaxYear component test #1980

MaxGhenis opened this issue Aug 18, 2024 · 0 comments · Fixed by #1979
Labels
bug Something isn't working tests Adding new tests or modifying existing tests

Comments

@MaxGhenis
Copy link
Contributor

MaxGhenis commented Aug 18, 2024

We're experiencing a consistent test failure in our CI pipeline for the TaxYear component. Both #1977 and #1979 are hitting it, despite them both being simple and unrelated. The test that's failing is attempting to simulate selecting a year from the dropdown, but it's unable to find the element by its title.

Failing Test:
File: src/__tests__/pages/household/input/TaxYear.test.js

The specific line causing the error is:

fireEvent.click(getByTitle(testYearOption));

Error Message:

TestingLibraryElementError: Unable to find an element with the title: [testYearOption].

Additional Context:

  • This issue started occurring recently, without any direct changes to the TaxYear component or its test file.
  • The test was passing as recently as 2 days ago (neither antd nor react-testing-library were updated since).
  • We've recently had updates to some of our dependencies, notably chore(deps): lock file maintenance jestjs/jest#15252 merged yesterday.
  • The error is reproducible in our CI environment but may not be reproducible locally.

Environment:

  • React version: 18.3.1
  • @testing-library/react version: 15.0.7
  • Jest version: 29.7.0
  • Ant Design version: >=5

Steps to Reproduce:

  1. Run the test suite for the TaxYear component
  2. Observe that the test "Properly sets state variable for year when selected" fails

Expected Behavior:
The test should be able to find and click on the year option in the dropdown, successfully setting the state variable for the year.

Actual Behavior:
The test fails to find the element with the specified title, causing the test to fail.

Attempted Solutions:
We've tried the following without success:

  • Clearing CI cache
  • Updating dependencies
  • Reviewing recent code changes

Next Steps:
We're considering the following to diagnose and resolve the issue:

  1. Adding more detailed logging in the test
  2. Trying different queries (e.g., getByText instead of getByTitle)
  3. Investigating potential timing issues with the Ant Design Select component
  4. Reviewing any recent changes to our test environment or CI configuration

Any insights or suggestions on how to resolve this issue would be greatly appreciated.

@MaxGhenis MaxGhenis added bug Something isn't working tests Adding new tests or modifying existing tests labels Aug 18, 2024
@github-project-automation github-project-automation bot moved this from Todo to Closed in policyengine-app Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tests Adding new tests or modifying existing tests
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

1 participant