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

Update from v9.9.2 to v9.10.2 breaks "input" value attribute with React Testing Library (getByText) #883

Closed
swernerx opened this issue May 2, 2023 · 1 comment · Fixed by #885
Assignees
Labels
bug Something isn't working

Comments

@swernerx
Copy link

swernerx commented May 2, 2023

I am not a direct user of happy-dom but I experience the following error when updating from v9.9.2 to v9.10.2 in my tests using React Testing Library.

The test tries to access the button via its label (value attribute on submit-input)

const { getByText, asFragment } = render(<Input />)
getByText("Submit Button")

The obviously simple test fails with:

TestingLibraryElementError: Unable to find an element with the text: Submit Button. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

after the update.

image

Installed dependencies:

  • "@testing-library/jest-dom": "^5.16.5"
  • "@testing-library/react": "^14.0.0"
  • "@vitejs/plugin-react": "^4.0.0"
  • "@vitejs/plugin-react-swc": "^3.3.0"
  • "happy-dom": "^9.10.2",
  • "vite": "^4.3.4"
  • "vitest": "^0.30.1"
@swernerx swernerx added the bug Something isn't working label May 2, 2023
@capricorn86 capricorn86 self-assigned this May 2, 2023
capricorn86 added a commit that referenced this issue May 2, 2023
capricorn86 added a commit that referenced this issue May 2, 2023
…-v9102-breaks-input-value-attribute-with-react-testing-library-getbytext

#883@patch: Fixes issue with attribute query selectors not using apos…
@capricorn86
Copy link
Owner

Thank you for reporting @swernerx! 🙂

The issue has been fixed now.

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v9.10.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants