Closed
Description
Describe the bug
Using a findBy
and findAllBy
query function on a selector returned by within
throws error:
1) Function that specifies a selector can only return a DOM node, an array of nodes, NodeList, HTMLCollection, null or undefined. Use ClientFunction to
return other values.
In my example the following works:
const group = screen.findByRole("group", { name: "My Group" });
await t
.expect(
within(group).getByRole("button", { name: "Increase B" }).exists
)
.ok();
while this one does not:
const group = screen.findByRole("group", { name: "My Group" });
await t
.expect(
within(group).findByRole("button", { name: "Increase B" }).exists
)
.ok();
It doesn't matter if I find the group
with findByRole
or getByRole
.
To Reproduce
You can find a reproducable example at https://github.com/nilshartmann/testcafe-within. The app in this repository is a create-react-app
-based example.
- Clone the repo
yarn install
yarn start
- in second terminal:
yarn testcafe
Testfile: https://github.com/nilshartmann/testcafe-within/blob/master/testcafe/within.test.ts
Versions:
"@testing-library/testcafe": "^4.3.0",
"testcafe": "^1.9.4"
Expected behavior
I'd expect that findBy
should also work with selectors from within
?
Desktop (please complete the following information):
- OS: 10.15.7
- Browser: firefox, chrome
- Version Chrome 87.0.4280.67