Skip to content

Conversation

@steliosmavro
Copy link

Summary

Adds a new ESLint rule to encourage the use of the apiClient fixture in API tests within Scout. The rule emits a warning if an API test does not use apiClient, guiding test authors to follow our best practice of using apiClient for endpoint validation rather than apiServices or kbnClient in the test body.

Why

  • Ensures API tests are explicit about which client is used for endpoint validation.
  • Reduces confusion and potential privilege issues caused by using apiServices or kbnClient directly in test bodies.

What changed

  • Introduced a new ESLint rule that checks for apiClient usage in API test blocks.
  • The rule emits a warning if apiClient is not used, but can be overridden with a comment in edge cases.

How to use

  • Write API tests as usual, ensuring that apiClient is used for the main endpoint validation.
  • If the rule triggers in a valid edge case, suppress the warning with an ESLint comment and add a justification.

@steliosmavro steliosmavro requested a review from a team as a code owner December 3, 2025 20:54
@cla-checker-service
Copy link

❌ Author of the following commits did not sign a Contributor Agreement:
6f780c7

Please, read and sign the above mentioned agreement if you want to contribute to this project

@steliosmavro steliosmavro added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Dec 3, 2025
@steliosmavro steliosmavro requested a review from csr December 3, 2025 21:27
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled in files

id before after diff
@kbn/eslint-plugin-eslint 0 2 +2

ESLint disabled line counts

id before after diff
@kbn/eslint-plugin-eslint 0 2 +2

Total ESLint disabled count

id before after diff
@kbn/eslint-plugin-eslint 0 4 +4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants