[9.2] [@kbn/eslint-plugin-eslint] Add scout rule to require global setup hook in parallel tests (#247219)#247410
Closed
kibanamachine wants to merge 1 commit intoelastic:9.2from
Closed
Conversation
…ok in parallel tests (elastic#247219) ## Summary Adds a new ESLint rule `scout_require_global_setup_hook_in_parallel_tests` that ensures `parallel_tests` directories contain a `global.setup.ts` file that calls `globalSetupHook`. Without this hook, ES security indexes are not pre-generated and tests become flaky. ## What it does The rule performs two checks: 1. Every `parallel_tests` directory must contain a `global.setup.ts` file 2. The `global.setup.ts` file must call `globalSetupHook` **Invalid:** ```ts // ❌ Missing global.setup.ts file in parallel_tests directory test/scout/ui/parallel_tests/ └── my_test.spec.ts // Error: directory must contain global.setup.ts // ❌ globalSetupHook imported but not called // test/scout/ui/parallel_tests/global.setup.ts import { globalSetupHook } from '@kbn/scout-security'; export const setup = async () => {}; // Error: must call globalSetupHook ``` **Valid:** ```ts // ✅ global.setup.ts with globalSetupHook call // test/scout/ui/parallel_tests/global.setup.ts import { globalSetupHook } from '@kbn/scout-security'; globalSetupHook('Ingest archives', async ({ esArchiver }) => {}); // ✅ Missing global.setup.ts in non-parallel tests directory (no error) test/scout/ui/tests/ └── my_test.spec.ts // OK: rule only applies to parallel_tests ``` ## Features - Validates that `parallel_tests` directories contain a `global.setup.ts` file - Validates that `global.setup.ts` calls `globalSetupHook` function - Reports only once per directory (not for every file in the directory) - Does not affect files outside `parallel_tests` directories ## Changes - Added rule implementation with filesystem check for `global.setup.ts` existence - Added test suite covering valid and invalid cases - Registered rule in plugin and enabled as error for Scout test files (cherry picked from commit fb35695)
Contributor
💔 Build Failed
Failed CI StepsHistory |
Contributor
|
Has been overwritten by new PR (and backported), so this current backport is no longer needed. |
auto-merge was automatically disabled
January 10, 2026 14:00
Pull request was closed
Contributor
|
Has been overwritten by new PR (and backported), so this current backport is no longer needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto9.2:Questions ?
Please refer to the Backport tool documentation