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

Name property does not exist in ByRoleOptions typing #636

Closed
eric-burel opened this issue Apr 14, 2020 · 4 comments
Closed

Name property does not exist in ByRoleOptions typing #636

eric-burel opened this issue Apr 14, 2020 · 4 comments

Comments

@eric-burel
Copy link

  • @testing-library/react version: 10.0.2

Relevant code or config:

Name is documented here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole

But absent from the "ByRole" typing.

What you did:

const checkbox2 = getByRole("checkbox", { name: "asset-2" });

What happened:

Argument of type '{ name: string; }' is not assignable to parameter of type 'ByRoleOptions'.
Object literal may only specify known properties, and 'name' does not exist in type 'ByRoleOptions'.ts(2345)

Reproduction:

Use getByRole in a ts file like in the code provided above.

Suggested solution:

Fix typings of the ByRole option

@eps1lon
Copy link
Member

eps1lon commented Apr 14, 2020

You need to manually update the typings for @testing-library/dom you have installed. The latest typings are up-to-date.

The underlying issue is already part of #620

@eps1lon eps1lon closed this as completed Apr 14, 2020
@eric-burel
Copy link
Author

Hi, thanks but I don't get why, upgrading does not work:

yarn upgrade --latest @types/testing-library__react

This will still install the old __dom typings within @types/testing-library-react. I've tried to install the dom typings separately, I get the lastest version but no luck, the react typings will still load the older types.

Do you have a quickfix for this?

@eps1lon
Copy link
Member

eps1lon commented Apr 14, 2020

yarn upgrade --latest @types/testing-library__react

You need to upgrade @types/testing-library__dom because Yarn will not upgrade dependencies of the package you are upgrading.

If that doesn't help remove the lockfile entry for @types/testing-library__dom and run yarn install again.

@eric-burel
Copy link
Author

Thanks it works after manually removing reference to testing-library__dom v6 and rerunning the yarn upgrade command.

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

No branches or pull requests

2 participants