Skip to content
This repository was archived by the owner on Mar 31, 2024. It is now read-only.

Commit 08d82ee

Browse files
author
Spencer
committed
[jest] disallow invalid describe calls (elastic#41378)
* [jest] disallow invalid describe calls * correct other describe calls * remove unnecessary glob * cast decribe names to strings * remove new async describe function # Conflicts: # test/functional/apps/dashboard/dashboard_filtering.js # x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts # x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js # x-pack/test/functional/apps/uptime/monitor.ts # x-pack/test_utils/jest/integration_tests/example_integration.test.ts
1 parent a79f418 commit 08d82ee

60 files changed

Lines changed: 102 additions & 92 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,16 @@ module.exports = {
361361
},
362362
},
363363

364+
/**
365+
* Jest specific rules
366+
*/
367+
{
368+
files: ['**/*.test.{js,ts,tsx}'],
369+
rules: {
370+
'jest/valid-describe': 'error',
371+
},
372+
},
373+
364374
/**
365375
* APM overrides
366376
*/

packages/kbn-pm/src/utils/projects.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ describe('#topologicallyBatchProjects', () => {
224224
expect(expectedBatches).toMatchSnapshot();
225225
});
226226

227-
describe('batchByWorkspace = true', async () => {
227+
describe('batchByWorkspace = true', () => {
228228
test('batches projects topologically based on their project dependencies and workspaces', async () => {
229229
const batches = topologicallyBatchProjects(projects, graph, { batchByWorkspace: true });
230230

packages/kbn-ui-framework/src/components/button/button.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('KuiButton', () => {
5656
describe('Props', () => {
5757
describe('buttonType', () => {
5858
BUTTON_TYPES.forEach(buttonType => {
59-
describe(buttonType, () => {
59+
describe(`${buttonType}`, () => {
6060
test(`renders the ${buttonType} class`, () => {
6161
const $button = render(
6262
<KuiButton

packages/kbn-ui-framework/src/components/button/button_icon/button_icon.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('KuiButtonIcon', () => {
4242
describe('Props', () => {
4343
describe('type', () => {
4444
ICON_TYPES.forEach(type => {
45-
describe(type, () => {
45+
describe(`${type}`, () => {
4646
test(`renders the ${type} class`, () => {
4747
const $buttonIcon = render(<KuiButtonIcon type={type} />);
4848
expect($buttonIcon).toMatchSnapshot();

packages/kbn-ui-framework/src/components/button/link_button.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('KuiLinkButton', () => {
5757
describe('Props', () => {
5858
describe('buttonType', () => {
5959
BUTTON_TYPES.forEach(buttonType => {
60-
describe(buttonType, () => {
60+
describe(`${buttonType}`, () => {
6161
test(`renders the ${buttonType} class`, () => {
6262
const $button = render(
6363
<KuiLinkButton

packages/kbn-ui-framework/src/components/button/submit_button.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('KuiSubmitButton', () => {
5555
describe('Props', () => {
5656
describe('buttonType', () => {
5757
BUTTON_TYPES.forEach(buttonType => {
58-
describe(buttonType, () => {
58+
describe(`${buttonType}`, () => {
5959
test(`renders the ${buttonType} class`, () => {
6060
const $button = render(<KuiSubmitButton buttonType={buttonType} />);
6161
expect($button).toMatchSnapshot();

packages/kbn-ui-framework/src/components/collapse_button/collapse_button.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('KuiCollapseButton', () => {
3131
describe('Props', () => {
3232
describe('direction', () => {
3333
DIRECTIONS.forEach(direction => {
34-
describe(direction, () => {
34+
describe(`${direction}`, () => {
3535
test(`renders the ${direction} class`, () => {
3636
const component = <KuiCollapseButton direction={direction} {...requiredProps}/>;
3737
expect(render(component)).toMatchSnapshot();

src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ describe('filter_manager', () => {
219219
});
220220
});
221221

222-
describe('add filters', async () => {
222+
describe('add filters', () => {
223223
test('app state should accept a single filter', async function() {
224224
updateSubscription = filterManager.getUpdates$().subscribe(updateListener);
225225
const f1 = getFilter(FilterStateStore.APP_STATE, false, false, 'age', 34);
@@ -535,7 +535,7 @@ describe('filter_manager', () => {
535535
});
536536
});
537537

538-
describe('remove filters', async () => {
538+
describe('remove filters', () => {
539539
test('remove on empty should do nothing and not fire events', async () => {
540540
updateSubscription = filterManager.getUpdates$().subscribe(updateListener);
541541
await filterManager.removeAll();

src/legacy/ui/public/courier/fetch/request/serialize_fetch_params/serialize_fetch_params.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('headers', () => {
8181
return JSON.parse(requestParts[0]);
8282
};
8383

84-
describe('search request preference', async () => {
84+
describe('search request preference', () => {
8585
test('should be set to sessionId when courier:setRequestPreference is "sessionId"', async () => {
8686
const config = {
8787
get: () => {

src/legacy/ui/public/kfetch/kfetch.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ describe('kfetch', () => {
133133
}
134134
});
135135

136-
describe('when throwing response error (KFetchError)', async () => {
136+
describe('when throwing response error (KFetchError)', () => {
137137
let error: KFetchError;
138138
beforeEach(async () => {
139139
fetchMock.get('*', { status: 404, body: { foo: 'bar' } });
@@ -348,7 +348,7 @@ describe('kfetch', () => {
348348
});
349349
});
350350

351-
describe('when interceptors return synchronously', async () => {
351+
describe('when interceptors return synchronously', () => {
352352
let resp: any;
353353
beforeEach(async () => {
354354
fetchMock.get('*', { foo: 'bar' });
@@ -381,7 +381,7 @@ describe('kfetch', () => {
381381
});
382382
});
383383

384-
describe('when interceptors return promise', async () => {
384+
describe('when interceptors return promise', () => {
385385
let resp: any;
386386
beforeEach(async () => {
387387
fetchMock.get('*', { foo: 'bar' });

0 commit comments

Comments
 (0)