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
feat: return more data from getSuggestedQuery to support tooling #608
Conversation
I've added more data to the returned object, to support the development of tooling. Before this change, the returned value would be something like `{ queryName: 'Role' }`, and only by calling the `toString` method, the caller would get more information (the full formatted expression). With this change, the caller gets more useful data, to build tooling around. Example result: ``` { queryName: 'Role', queryMethod: 'getByRole', queryArgs: ['button', { name: /submit/i }], variant: 'get' } ``` The variant now defaults to `get`, to fix a bug that was causing suggestions like `undefinedByRole(…)` to be generated.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit fcdf49b:
|
@kentcdodds , I'm not sure how to make travis happy. It's failing on Is something off in dom-testing-library on patch-1 is 📦 v0.0.0-semantically-released
➜ npm run validate
> @testing-library/dom@0.0.0-semantically-released validate /home/smeijer/dev/dom-testing-library
> kcd-scripts validate
[typecheck] internal/modules/cjs/loader.js:985
[typecheck] throw err;
[typecheck] ^
[typecheck]
[typecheck] Error: Cannot find module 'typescript' |
@smeijer this is probably because the code coverage doesn't reach 100% |
@timdeschryver, thanks! That makes sense. A more descriptive error would have helped. I'll take a look at it tomorrow, see if I can bump it back to 💯 *edit, I see now. I should have read the log better. [test] Jest: "global" coverage threshold for branches (100%) not met: 99.72%
[test]
[test] Test Suites: 28 passed, 28 total
[test] Tests: 538 passed, 538 total
[test] Snapshots: 123 passed, 123 total
[test] Time: 82.1 s
[test] Ran all test suites in 2 projects.
[test] npm run test --silent -- --coverage exited with code 1 |
Codecov Report
@@ Coverage Diff @@
## master #608 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 550 555 +5
Branches 137 138 +1
=========================================
+ Hits 550 555 +5
Continue to review full report at Codecov.
|
Awesome. I'm ready 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super 👍
@all-contributors please add @smeijer for code and tests |
I've put up a pull request to add @smeijer! 🎉 |
🎉 This PR is included in version 7.11.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Thanks so much for your help! I've added you as a collaborator on the project. Please make sure that you review the |
Thank you so much @kentcdodds! I'll make sure to read the docs. 😇 |
What:
1. Return rich data from
getSuggestedQuery
I've added more data to the object that
getSuggestedQuery
returns. Before this change, the returned value would be something like:By calling the
toString
method, the caller would get more information, but formatted as string: (the full expression statement)With this change, the caller gets rich data, upon which he can build tooling.
Example result:
2. Change formatting of the suggested query
Before this change, queries were returned with double quotes and without spacing. I've updated the
toString()
method to match the style that's being used throughout the docs.3. Fix a small bug
The variant now defaults to
get
, to fix a bug that was causing suggestions likeundefinedByRole(…)
to be generated.Why:
To support the development of tools around query suggestions.
How:
Checklist:
docs site
DefinitelyTyped
This PR fixes 3 related things. Let me know if you want me to break things up in separate branches.
Also, if you're not comfortable with the suggestion style change (single quotes and spaces in expression arguments), let me know, and I can undo that part.