Skip to content

docs: fix reference error in code sample #947

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

Merged
merged 3 commits into from
Oct 6, 2021

Conversation

lukeingalls
Copy link
Contributor

No description provided.

@@ -51,8 +51,8 @@ export function getByTestId(...args) {
const result = getAllByTestId(...args)
if (result.length > 1) {
throw queryHelpers.getElementError(
`Found multiple elements with the [data-test-id="${id}"]`,
container,
`Found multiple elements with the [data-test-id="${args.id}"]`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the current example isn't correct, I think that suggestion also isn't valid.
args is an array in this case, so accessing id and container won't work.

I can't make a suggestion on the getByTestId method, but I believe the arguments should be:

export function getByTestId(container, id, ...rest) 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you are right I'll correct it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more thingy,

- const result = getAllByTestId(...args)
+ const result = getAllByTestId(container, id, ...rest)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, thank you. I swear I've written code before 😅

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lukeingalls

@timdeschryver timdeschryver merged commit 8b7b466 into testing-library:main Oct 6, 2021
@timdeschryver
Copy link
Member

@all-contributors please add @lukeingalls for docs

@allcontributors
Copy link
Contributor

@timdeschryver

I've put up a pull request to add @lukeingalls! 🎉

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

Successfully merging this pull request may close these issues.

2 participants