-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[@kbn/eslint-plugin-eslint] Add ESlint rule to allow max one describe call per fixture
#245464
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
base: main
Are you sure you want to change the base?
[@kbn/eslint-plugin-eslint] Add ESlint rule to allow max one describe call per fixture
#245464
Conversation
|
| // No describe blocks at all | ||
| { | ||
| code: dedent` | ||
| test('should work', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| `, | ||
| }, |
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.
tbh not sure about it, but let's leave it as is for now
| test.describe('outer suite', () => { | ||
| describe('inner suite', () => { | ||
| test('should work', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| }); | ||
| }); |
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.
| describe('my test suite', () => { | ||
| describe('nested suite', () => { | ||
| test('should work', () => { | ||
| expect(true).toBe(true); | ||
| }); | ||
| }); | ||
| }); |
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.
Afaik this is will be interpreted as Jest test suites. Please double check
| apiTest.describe('first suite', () => { | ||
| apiTest('test 1', () => {}); | ||
| }); | ||
|
|
||
| apiTest.describe('second suite', () => { | ||
| apiTest('test 2', () => {}); | ||
| }); |
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.
This is exactly the problem we try to detect!
| /** @typedef {import("@typescript-eslint/typescript-estree").TSESTree.CallExpression} CallExpression */ | ||
| /** @typedef {import("@typescript-eslint/typescript-estree").TSESTree.MemberExpression} MemberExpression */ | ||
|
|
||
| const ERROR_MSG = 'Only one describe block is allowed per test type (apiTest, test, or spaceTest).'; |
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.
I think we need to explain it is required for auto-skip functionality in CI. This argument should hopefully minimize interest to disable the rule.
dmlemeshko
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.
I left few nits 👏
d82fa37 to
08e195b
Compare
08e195b to
c52fe40
Compare
💔 Build Failed
Failed CI StepsHistory
|

Summary
Adds a new ESLint rule
scout_max_one_describethat enforces a maximum of onedescribeblock per test type in Scout tests to maintain consistent test structure.What it does
Scout tests support multiple test fixtures (
apiTest,test,spaceTest), and each fixture type should only have one top-leveldescribeblock per file. This rule prevents multipledescribeblocks for the same test type, which can lead to fragmented test organization.Invalid:
Valid:
Features
apiTest.describe(),test.describe(), andspaceTest.describe()calls independentlyChanges
.eslintrc.js