From cdbb0d7dcf8c2389072e4334fd207674eb5c10ff Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Thu, 6 Feb 2025 11:47:48 -0700 Subject: [PATCH] Remove jest/no-conditional-in-test rule I propose that we remove this rule. I would argue that adding logic to tests is not as harmful as the docs for this rule would indicate and in fact can be quite useful. - When mocking functions with overloads, it is necessary to add logic inside of the mock implementation to handle different arguments. - When testing a function that can be called multiple ways where the behavior is mostly the same between inputs aside from a few edge cases, using an `if` statement to highlight the difference can be useful. --- packages/jest/rules-snapshot.json | 1 - packages/jest/src/index.mjs | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/jest/rules-snapshot.json b/packages/jest/rules-snapshot.json index bd793dfb..e34a1ca2 100644 --- a/packages/jest/rules-snapshot.json +++ b/packages/jest/rules-snapshot.json @@ -4,7 +4,6 @@ "jest/no-alias-methods": "warn", "jest/no-commented-out-tests": "warn", "jest/no-conditional-expect": "error", - "jest/no-conditional-in-test": "error", "jest/no-deprecated-functions": "error", "jest/no-disabled-tests": "warn", "jest/no-done-callback": "error", diff --git a/packages/jest/src/index.mjs b/packages/jest/src/index.mjs index a3199001..cc90069d 100644 --- a/packages/jest/src/index.mjs +++ b/packages/jest/src/index.mjs @@ -19,7 +19,6 @@ const config = createConfig({ rules: { 'jest/consistent-test-it': ['error', { fn: 'it' }], 'jest/no-duplicate-hooks': 'error', - 'jest/no-conditional-in-test': 'error', 'jest/no-test-return-statement': 'error', 'jest/prefer-hooks-on-top': 'error', 'jest/prefer-lowercase-title': ['error', { ignore: ['describe'] }],