- Notifications
You must be signed in to change notification settings - Fork 410
Open
Description
@testing-library/jest-domversion: 5.16.5nodeversion: 16.16.0npm(oryarn) version: 9.1.2@testing-library/react: 13.4.0@testing-library/user-event: 14.4.3react: 18.2.0
Relevant code or config:
productive code
import { DuetButton } from '@duetds/react'; // ... <DuetButton onClick={props.someCallback} disabled={someState}> some name </DuetButton>test code
const button= screen.getByRole('button', { name: /some name/i }); expect(button).toBeDisabled(); // works ok // change the state expect(button).toBeEnabled(); // fails although the button is enabledWhat you did:
- there is a test working well with a HTML button or with React Bootstrap button
- when the button is replaced with a button from the [duet] library, which is using web-components implemented with stencil, there is a problem with the
toBeEnabled()matcher - the property
disabledwith the value"false"is evaluated like if it was disabled - the testing of the same code with Playwright works just fine and the the button is recognized as enabled
What happened:
Error: expect(element).toBeEnabled() Received element is not enabled: <duet-button class="sc-duet-button-h hydrated" disabled="false" /> Reproduction:
- unfortunately the codesendbox doesn't work for me
in a react project
- npm i @duetds/react
- add a
- test the button's disabled status
getByRoledidn't always work, butgetByTextworks
Problem description:
- an enabled button is treated like a disabled one in tests
Suggested solution:
- only when the property
disabledistrue,toBeEnabled()returns false
Metadata
Metadata
Assignees
Labels
No labels