Skip to content

Update docs to mention buggy behavior of getByTestId and queryByTestId #303

Closed
@thymikee

Description

@thymikee

Describe the Feature

Add a warnings under getByTestId and queryByTestId queries:

> Current implementation has a serious flaw, which results in finding more IDs than there really is in native host React components. Fixing it may break some of your tests so we'll do it in next major release (v2). As a mitigation, please use `getAllByTestId('your-id')[0]` or migrate off of testing with testID, which is considered unsafe.

And a second one, a bit unrelated by why not:

> Please be mindful when using this API and **treat it as an escape hatch**. Your users can't interact with `testID` anyhow, so you may end up writing tests that provide false sense of security. Favor text and accessibility queries instead. 

Related Issues

See #270

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions