testing-library / testing-library/eslint-plugin-testing-library
Internal: generate tests for all supported frameworks per rule
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 168
- Avg merge
- 15h 44m
- Merged PRs (30d)
- 14
Description
Plugin version
v5
What problem do you want to solve?
Quoting myself from #588:
Thinking about all the changes we did to test all rules for the corresponding Testing Library frameworks, I think it makes sense to add some improvements to our TestingLibraryRuleMeta and createRuleTester to automatically generate the test cases variations for indicated frameworks.
Your take on the correct solution?
In my mind, it could look like this:
// rules/foo.js
export default createTestingLibraryRule({
// ...
meta: {
// ...
supportedFrameworks: ['react', 'vue']
// ^ we extend our TestingLibraryRuleMeta so it has this new required property,
// which can be used also to autogenerate a table of compatible frameworks for each rule doc
}
})
// test/lib/rules/foo.js
ruleTester.run(RULE_NAME, rule, {
valid: [
{
code: `
import { fireEvent } from '{TESTING_LIBRARY_FRAMEWORK}'
// ^ this placeholder gets replaced automatically,
// iterating over each value from supportedFrameworks
await fireEvent.click(element)
`
}
]
})
Anything else?
No response
Do you want to submit a pull request to implement this change?
Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the TestingLibraryRuleMeta and createRuleTester implementations, then compare the rule and test locations shown in rules/foo.js and test/lib/rules/foo.js. Check issue #588 for the existing framework-testing changes. Done means supportedFrameworks is represented in rule metadata and test cases can generate framework variations from the placeholder pattern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript, typescript
- Domain
- testing-qa, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100