-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore(eslint): Add lint rules for disabled or focused tests #8489
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
Conversation
size-limit report 📦
|
mydea
left a comment
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
AbhiPrasad
left a comment
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-jestpackage which contains a bunch of jest-syntax-specific rulesno-focused-testsrule to throw a lint error if a test is focused withit.only,fitor similar functions.no-disabled-testsrule to throw a lint error if a test (suite) from a suite is disabled/skipped withit.skip,xitor 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-jestis 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 (
sentryTestinstead oftest) which these rules cannot detect. I tried setting the global aliases setting but it didn't work becausesentryTestis imported and hence not considered a global. We can revisit adding a custom rule for this later.