-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
chore(eslint): Add lint rules for disabled or focused tests #8489
Conversation
size-limit report 📦
|
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.
nice one!
20002e8
to
7858d95
Compare
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.
Limitation: Our Playwright browser integration tests use a custom test function (sentryTest instead of test) which these rules cannot detect. I tried setting the global aliases setting but it didn't work because sentryTest is imported and hence not considered a global. We can revisit adding a custom rule for this later.
We don't have to worry about playwright for test.only
because we can turn on
sentry-javascript/packages/e2e-tests/test-applications/create-next-app/playwright.config.ts
Line 29 in 192b956
forbidOnly: !!process.env.CI, |
test.skip
is still a problem I guess.
7858d95
to
dd2dffb
Compare
We sometimes forget to remove focused or disabled annotations after debugging tests. This of course isn't ideal and as brought up in #8485 we should add checks against this. Therefore, this PR:
eslint-plugin-jest
package which contains a bunch of jest-syntax-specific rulesno-focused-tests
rule to throw a lint error if a test is focused withit.only
,fit
or similar functions.no-disabled-tests
rule to throw a lint error if a test (suite) from a suite is disabled/skipped withit.skip
,xit
or similar functions. While we sometimes skip tests on purpose, I'd argue that we generally want to avoid this, as it can also happen accidentally. For the few exceptions of this rule, we can always ignore it.If reviewers want to avoid adding another dependency to the project, we can also extract the rules and vendor them. However, I'd argue that adding
eslint-plugin-jest
is probably the simplest way to enable this rules and we might want to enable other rules in the future (e.g.no-conditional-expects
).This rule also works with vitest syntax which we use in the SvelteKit package.
Limitation: Our Playwright browser integration tests use a custom test function (
sentryTest
instead oftest
) which these rules cannot detect. I tried setting the global aliases setting but it didn't work becausesentryTest
is imported and hence not considered a global. We can revisit adding a custom rule for this later.