Skip to content
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

expect-expect fails even if expectTypeOf is present #382

Closed
mrmckeb opened this issue Mar 5, 2024 · 7 comments · Fixed by #386
Closed

expect-expect fails even if expectTypeOf is present #382

mrmckeb opened this issue Mar 5, 2024 · 7 comments · Fixed by #386

Comments

@mrmckeb
Copy link
Contributor

mrmckeb commented Mar 5, 2024

This may be intentional, but we have some tests that only check types and these are being flagged for failing to include expect statements.

@mrmckeb
Copy link
Contributor Author

mrmckeb commented Mar 5, 2024

I should note that I'm happy to make a PR for this if you want the help!

@veritem
Copy link
Owner

veritem commented Mar 6, 2024

@mrmckeb a pr is always welcome :D

@mrmckeb
Copy link
Contributor Author

mrmckeb commented Mar 6, 2024

So thinking about this, and these checks don't actually run unless Vitest is run with --typecheck or the typecheck config option is set.

Perhaps a rule is also required that warns you if you're using these assertions, but haven't enabled that option in your config?

@veritem
Copy link
Owner

veritem commented Mar 6, 2024

I should have included the edge case for types when designing the rule that is my bad. What you'll have todo for this pr is to check if expectTypeOf exists in test body and return, exiting the rule.

@mrmckeb
Copy link
Contributor Author

mrmckeb commented Mar 6, 2024

Understood, thanks! I have a bit of rule-writing experience so that should be fine 🤞

My concern was more, should this be the default behaviour? If you don't have typecheck enabled in your config, then this is the same as having no expects at all.
https://vitest.dev/api/expect-typeof

I can consider that in the work I do though, thanks! :)

@veritem
Copy link
Owner

veritem commented Mar 6, 2024

Definitely, look into a way of knowing whether --typecheck has been enabled and then enable the condition.

@mrmckeb
Copy link
Contributor Author

mrmckeb commented Mar 8, 2024

Done! Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants