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
test: use uvu to run rule tests for better reports #257
Conversation
cbe5f6a
to
8a23cda
Compare
Cool, this is much better and will definitely save a considerable debugging time. Thank you for that! 🥇 I liked the second option better... but I have a suggestion, to avoid too much nesting we could move the const valid = [
// ...
]
const invalid = [
// ...
]
test(__filename, () => {
ruleTester().run(path.parse(__filename).name, rule, { valid, invalid })
}
test.run() |
That's a great idea! |
8a23cda
to
5b764b4
Compare
Something like this @rafaelss95 ? |
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.
Some minor comments, but overall it looks pretty good. 🥳
{}, | ||
on(), | ||
)`, | ||
] |
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.
I'd add this where possible:
] | |
] as const |
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.
Where would this be needed?
path.parse(__filename).name, | ||
rule, | ||
type MessageIds = ESLintUtils.InferMessageIdsTypeFromRule<typeof rule> | ||
type Options = ESLintUtils.InferOptionsTypeFromRule<typeof rule>[0][] |
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.
Still had to do [0][]
here to get the types correct, [option]
vs option[]
Merging this in so other tests can be changed without affecting this merge. |
🎉 This PR is included in version 1.46.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Currently, running the rule tests is not friendly because it abruptly stops when a rule test fails.
It also doesn't show why it fails.
In this PR, we're going to resolve this because it can waste some time and it was on my todo list 😅
The trick is to run the tests in an uvu context, with it uvu will:
As a fix, we got two options and I would like to hear your opinion @rafaelss95 before I migrate the other rules.
We could either do it like
avoid-combining-selectors
, and export the tests (we should then also rename them to fixtures to make it clear) and then iterate over them, and create a test for each fixture. This gives us a good overview (name of the fixture, and the formatted exception).The other option is to keep the rules test in place but wrap them in an uvu test, like did for
avoid-cyclic-effects