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

chore(eslint): Add lint rules for disabled or focused tests #8489

Merged
merged 5 commits into from
Jul 19, 2023

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Jul 11, 2023

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:

  • Adds the eslint-plugin-jest package which contains a bunch of jest-syntax-specific rules
  • Enables the no-focused-tests rule to throw a lint error if a test is focused with it.only, fit or similar functions.
  • Enables the no-disabled-tests rule to throw a lint error if a test (suite) from a suite is disabled/skipped with it.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 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.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 11, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 21.95 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 69.13 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 20.28 KB (-0.01% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 60.38 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 21.9 KB (0%)
@sentry/browser - Webpack (minified) 71.51 KB (0%)
@sentry/react - Webpack (gzipped + minified) 21.92 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 50.58 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 30.11 KB (0%)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 28.16 KB (-0.01% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 49.42 KB (-0.01% 🔽)
@sentry/replay - Webpack (gzipped + minified) 43.1 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 69.51 KB (0%)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.82 KB (-0.01% 🔽)

@Lms24 Lms24 requested review from mydea and AbhiPrasad July 11, 2023 08:47
@Lms24 Lms24 marked this pull request as ready for review July 11, 2023 08:47
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one!

@Lms24 Lms24 force-pushed the lms/chore-add-test-eslint-rules branch from 20002e8 to 7858d95 Compare July 12, 2023 14:49
Copy link
Member

@AbhiPrasad AbhiPrasad left a 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

test.skip is still a problem I guess.

@Lms24 Lms24 force-pushed the lms/chore-add-test-eslint-rules branch from 7858d95 to dd2dffb Compare July 13, 2023 13:19
@Lms24 Lms24 merged commit ed889bc into develop Jul 19, 2023
67 checks passed
@Lms24 Lms24 deleted the lms/chore-add-test-eslint-rules branch July 19, 2023 08:27
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 this pull request may close these issues.

None yet

3 participants