Skip to content

TypeError: references is not iterable / cant parse expect(findBy*) #48

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

Closed
lkostrowski opened this issue Nov 25, 2019 · 4 comments · Fixed by #50
Closed

TypeError: references is not iterable / cant parse expect(findBy*) #48

lkostrowski opened this issue Nov 25, 2019 · 4 comments · Fixed by #50
Labels
bug Something isn't working released

Comments

@lkostrowski
Copy link

lkostrowski commented Nov 25, 2019

Error stack

TypeError: references is not iterable
Occurred while linting /Users/lukaszostrowski/projects/mp/src/app/flowers/__tests__/flowers-test.tsx:1

TypeError: references is not iterable
Occurred while linting /Users/lukaszostrowski/projects/mp/src/app/flowers/__tests__/flowers-test.tsx:1
    at Program:exit.testingLibraryQueryUsage.forEach.node (/Users/lukaszostrowski/projects/mp/node_modules/eslint-plugin-testing-library/lib/rules/await-async-query.js:61:37)
    at Array.forEach (<anonymous>)
    at Program:exit (/Users/lukaszostrowski/projects/mp/node_modules/eslint-plugin-testing-library/lib/rules/await-async-query.js:38:34)
    at listeners.(anonymous function).forEach.listener (/Users/lukaszostrowski/projects/mp/node_modules/eslint/lib/linter/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/lukaszostrowski/projects/mp/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/lukaszostrowski/projects/mp/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/Users/lukaszostrowski/projects/mp/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.leaveNode (/Users/lukaszostrowski/projects/mp/node_modules/eslint/lib/linter/node-event-generator.js:306:14)
    at CodePathAnalyzer.leaveNode (/Users/lukaszostrowski/projects/mp/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:655:23)
Process finished with exit code -1

Probably related code:
https://github.com/Belco90/eslint-plugin-testing-library/blob/b38689c69702f08954b456d03752d73b1bee7171/lib/rules/await-async-query.js#L38

Can't provide right now an example , I have to strip few hundreds lines, but maybe its just a matter of checking for references if its actually an array?

Also basing on code it should be expecting await from query, I believe only find* queries should be matched.

I don't have any of them top level, I have few expect(findBy*()).resolves. When I remove them, error is gone

@lkostrowski lkostrowski changed the title TypeError: references is not iterable TypeError: references is not iterable / cant parse expect(findBy*) Nov 25, 2019
@Belco90 Belco90 added the bug Something isn't working label Nov 25, 2019
@Belco90
Copy link
Member

Belco90 commented Dec 3, 2019

I hope I can go back to this in Christmas when I have some spare time. Sorry!

@tknickman
Copy link
Contributor

Just ran into this as well. I can look into a PR later on

@thomaslombart
Copy link
Collaborator

thomaslombart commented Dec 10, 2019

I opened a PR about that. Sorry about the delay, I had little spare time lately!

@Belco90 This issue hides, however, another issue. Indeed, we are not handling the case where a user wraps a query in an expect statement and then uses resolves or rejects. For example, the following statement will trigger an error even if it's a valid case:

expect(findByText("foo")).resolves.toBe("bar")

I'm opening up another issue 🙂

@Belco90
Copy link
Member

Belco90 commented Dec 10, 2019

🎉 This issue has been resolved in version 1.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
4 participants