Skip to content
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

[jest] disallow invalid describe calls #41378

Merged
merged 7 commits into from Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintrc.js
Expand Up @@ -361,6 +361,16 @@ module.exports = {
},
},

/**
* Jest specific rules
*/
{
files: ['**/*.test.{js,ts,tsx}'],
rules: {
'jest/valid-describe': 'error',
},
},

/**
* APM overrides
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/utils/projects.test.ts
Expand Up @@ -224,7 +224,7 @@ describe('#topologicallyBatchProjects', () => {
expect(expectedBatches).toMatchSnapshot();
});

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

Expand Down
Expand Up @@ -56,7 +56,7 @@ describe('KuiButton', () => {
describe('Props', () => {
describe('buttonType', () => {
BUTTON_TYPES.forEach(buttonType => {
describe(buttonType, () => {
describe(`${buttonType}`, () => {
test(`renders the ${buttonType} class`, () => {
const $button = render(
<KuiButton
Expand Down
Expand Up @@ -42,7 +42,7 @@ describe('KuiButtonIcon', () => {
describe('Props', () => {
describe('type', () => {
ICON_TYPES.forEach(type => {
describe(type, () => {
describe(`${type}`, () => {
test(`renders the ${type} class`, () => {
const $buttonIcon = render(<KuiButtonIcon type={type} />);
expect($buttonIcon).toMatchSnapshot();
Expand Down
Expand Up @@ -57,7 +57,7 @@ describe('KuiLinkButton', () => {
describe('Props', () => {
describe('buttonType', () => {
BUTTON_TYPES.forEach(buttonType => {
describe(buttonType, () => {
describe(`${buttonType}`, () => {
test(`renders the ${buttonType} class`, () => {
const $button = render(
<KuiLinkButton
Expand Down
Expand Up @@ -55,7 +55,7 @@ describe('KuiSubmitButton', () => {
describe('Props', () => {
describe('buttonType', () => {
BUTTON_TYPES.forEach(buttonType => {
describe(buttonType, () => {
describe(`${buttonType}`, () => {
test(`renders the ${buttonType} class`, () => {
const $button = render(<KuiSubmitButton buttonType={buttonType} />);
expect($button).toMatchSnapshot();
Expand Down
Expand Up @@ -31,7 +31,7 @@ describe('KuiCollapseButton', () => {
describe('Props', () => {
describe('direction', () => {
DIRECTIONS.forEach(direction => {
describe(direction, () => {
describe(`${direction}`, () => {
test(`renders the ${direction} class`, () => {
const component = <KuiCollapseButton direction={direction} {...requiredProps}/>;
expect(render(component)).toMatchSnapshot();
Expand Down
Expand Up @@ -219,7 +219,7 @@ describe('filter_manager', () => {
});
});

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

describe('remove filters', async () => {
describe('remove filters', () => {
test('remove on empty should do nothing and not fire events', async () => {
updateSubscription = filterManager.getUpdates$().subscribe(updateListener);
await filterManager.removeAll();
Expand Down
Expand Up @@ -81,7 +81,7 @@ describe('headers', () => {
return JSON.parse(requestParts[0]);
};

describe('search request preference', async () => {
describe('search request preference', () => {
test('should be set to sessionId when courier:setRequestPreference is "sessionId"', async () => {
const config = {
get: () => {
Expand Down
6 changes: 3 additions & 3 deletions src/legacy/ui/public/kfetch/kfetch.test.ts
Expand Up @@ -133,7 +133,7 @@ describe('kfetch', () => {
}
});

describe('when throwing response error (KFetchError)', async () => {
describe('when throwing response error (KFetchError)', () => {
let error: KFetchError;
beforeEach(async () => {
fetchMock.get('*', { status: 404, body: { foo: 'bar' } });
Expand Down Expand Up @@ -348,7 +348,7 @@ describe('kfetch', () => {
});
});

describe('when interceptors return synchronously', async () => {
describe('when interceptors return synchronously', () => {
let resp: any;
beforeEach(async () => {
fetchMock.get('*', { foo: 'bar' });
Expand Down Expand Up @@ -381,7 +381,7 @@ describe('kfetch', () => {
});
});

describe('when interceptors return promise', async () => {
describe('when interceptors return promise', () => {
let resp: any;
beforeEach(async () => {
fetchMock.get('*', { foo: 'bar' });
Expand Down
Expand Up @@ -52,7 +52,7 @@ export default function ({ getService }) {
const getSavedObjectTypesQuery = types => coerceToArray(types).map(type => `savedObjectTypes=${type}`).join('&');
const defaultQuery = getSavedObjectTypesQuery(['visualization', 'index-pattern', 'search', 'dashboard']);

describe('searches', async () => {
describe('searches', () => {
it('should validate search response schema', async () => {
await supertest
.get(`${baseApiUrl}/search/960372e0-3224-11e8-a572-ffca06da1357?${defaultQuery}`)
Expand Down Expand Up @@ -145,7 +145,7 @@ export default function ({ getService }) {
});
});

describe('dashboards', async () => {
describe('dashboards', () => {
it('should validate dashboard response schema', async () => {
await supertest
.get(`${baseApiUrl}/dashboard/b70c7ae0-3224-11e8-a572-ffca06da1357?${defaultQuery}`)
Expand Down Expand Up @@ -240,7 +240,7 @@ export default function ({ getService }) {
});
});

describe('visualizations', async () => {
describe('visualizations', () => {
it('should validate visualization response schema', async () => {
await supertest
.get(`${baseApiUrl}/visualization/a42c0580-3224-11e8-a572-ffca06da1357?${defaultQuery}`)
Expand Down Expand Up @@ -320,7 +320,7 @@ export default function ({ getService }) {
});
});

describe('index patterns', async () => {
describe('index patterns', () => {
it('should validate visualization response schema', async () => {
await supertest
.get(`${baseApiUrl}/index-pattern/8963ca30-3224-11e8-a572-ffca06da1357?${defaultQuery}`)
Expand Down
Expand Up @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) {
const browser = getService('browser');
const dashboardAddPanel = getService('dashboardAddPanel');

describe('create and add embeddables', async () => {
describe('create and add embeddables', () => {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('few panels');
});
Expand Down
8 changes: 4 additions & 4 deletions test/functional/apps/dashboard/dashboard_filter_bar.js
Expand Up @@ -27,12 +27,12 @@ export default function ({ getService, getPageObjects }) {
const pieChart = getService('pieChart');
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize']);

describe('dashboard filter bar', async () => {
describe('dashboard filter bar', () => {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
});

describe('Add a filter bar', async function () {
describe('Add a filter bar', function () {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
});
Expand All @@ -50,7 +50,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('filter editor field list', async function () {
describe('filter editor field list', function () {
this.tags(['skipFirefox']);

before(async () => {
Expand Down Expand Up @@ -80,7 +80,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('filter pills', async function () {
describe('filter pills', function () {
before(async () => {
await filterBar.ensureFieldEditorModalIsClosed();
await PageObjects.dashboard.gotoDashboardLandingPage();
Expand Down
10 changes: 5 additions & 5 deletions test/functional/apps/dashboard/dashboard_filtering.js
Expand Up @@ -34,13 +34,13 @@ export default function ({ getService, getPageObjects }) {
const dashboardPanelActions = getService('dashboardPanelActions');
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize']);

describe('dashboard filtering', async function () {
describe('dashboard filtering', function () {
this.tags('smoke');
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
});

describe('adding a filter that excludes all data', async () => {
describe('adding a filter that excludes all data', () => {
before(async () => {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();
Expand Down Expand Up @@ -107,7 +107,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('using a pinned filter that excludes all data', async () => {
describe('using a pinned filter that excludes all data', () => {
before(async () => {
await filterBar.toggleFilterPinned('bytes');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -169,7 +169,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('disabling a filter unfilters the data on', async () => {
describe('disabling a filter unfilters the data on', () => {
before(async () => {
await filterBar.toggleFilterEnabled('bytes');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -227,7 +227,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('nested filtering', async () => {
describe('nested filtering', () => {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
});
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/dashboard_listing.js
Expand Up @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.initTests();
});

describe('create prompt', async () => {
describe('create prompt', () => {
it('appears when there are no dashboards', async function () {
const promptExists = await PageObjects.dashboard.getCreateDashboardPromptExists();
expect(promptExists).to.be(true);
Expand Down Expand Up @@ -59,7 +59,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('delete', async function () {
describe('delete', function () {
it('default confirm action is cancel', async function () {
await PageObjects.dashboard.searchForDashboardWithName(dashboardName);
await PageObjects.dashboard.checkDashboardListingSelectAllCheckbox();
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/dashboard_options.js
Expand Up @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const PageObjects = getPageObjects(['dashboard']);

describe('dashboard data-shared attributes', async () => {
describe('dashboard data-shared attributes', () => {
let originalTitles = [];

before(async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/dashboard_query_bar.js
Expand Up @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }) {
const queryBar = getService('queryBar');
const PageObjects = getPageObjects(['dashboard', 'discover']);

describe('dashboard query bar', async () => {
describe('dashboard query bar', () => {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('dashboard with filter');
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/dashboard_time.js
Expand Up @@ -56,7 +56,7 @@ export default function ({ getPageObjects, getService }) {
});
});

describe('dashboard with stored timed', async function () {
describe('dashboard with stored timed', function () {
it('is saved with time', async function () {
await PageObjects.dashboard.switchToEditMode();
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/embed_mode.js
Expand Up @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['dashboard', 'common']);
const browser = getService('browser');

describe('embed mode', async () => {
describe('embed mode', () => {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('few panels');
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/empty_dashboard.js
Expand Up @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) {
const dashboardAddPanel = getService('dashboardAddPanel');
const PageObjects = getPageObjects(['dashboard']);

describe('empty dashboard', async () => {
describe('empty dashboard', () => {
before(async () => {
await PageObjects.dashboard.clickNewDashboard();
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/full_screen_mode.js
Expand Up @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }) {
const dashboardPanelActions = getService('dashboardPanelActions');
const PageObjects = getPageObjects(['dashboard', 'common']);

describe('full screen mode', async () => {
describe('full screen mode', () => {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('few panels');
});
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/view_edit.js
Expand Up @@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('shows lose changes warning', async function () {
describe('shows lose changes warning', function () {
describe('and loses changes on confirmation', function () {
beforeEach(async function () {
await PageObjects.dashboard.gotoDashboardEditMode(dashboardName);
Expand Down Expand Up @@ -195,7 +195,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('Does not show lose changes warning', async function () {
describe('Does not show lose changes warning', function () {
it('when time changed is not stored with dashboard', async function () {
await PageObjects.dashboard.gotoDashboardEditMode(dashboardName);
await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: false });
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/discover/_discover.js
Expand Up @@ -381,7 +381,7 @@ export default function ({ getService, getPageObjects }) {
}
});

describe('query #2, which has an empty time range', async () => {
describe('query #2, which has an empty time range', () => {
const fromTime = '1999-06-11 09:22:11.000';
const toTime = '1999-06-12 11:21:04.000';

Expand All @@ -402,7 +402,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('filter editor', async function () {
describe('filter editor', function () {
it('should add a phrases filter', async function () {
await filterBar.addFilter('extension.raw', 'is one of', 'jpg');
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true);
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/visualize/_markdown_vis.js
Expand Up @@ -29,15 +29,15 @@ export default function ({ getPageObjects, getService }) {
<h3>Inline HTML that should not be rendered as html</h3>
`;

describe('visualize app', async () => {
describe('visualize app', () => {
before(async function () {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickMarkdownWidget();
await PageObjects.visualize.setMarkdownTxt(markdown);
await PageObjects.visualize.clickGo();
});

describe('markdown vis', async () => {
describe('markdown vis', () => {

it('should not have inspector enabled', async function () {
await inspector.expectIsNotEnabled();
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_pie_chart.js
Expand Up @@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';

describe('pie chart', async function () {
describe('pie chart', function () {
const vizName1 = 'Visualization PieChart';
before(async function () {
log.debug('navigateToApp visualize');
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_point_series_options.js
Expand Up @@ -184,7 +184,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('timezones', async function () {
describe('timezones', function () {
const expectedLabels = [
'2015-09-20 00:00',
'2015-09-21 00:00',
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_tile_map.js
Expand Up @@ -209,7 +209,7 @@ export default function ({ getService, getPageObjects }) {

});

describe('Only request data around extent of map option', async () => {
describe('Only request data around extent of map option', () => {

it('when checked adds filters to aggregation', async () => {
const vizName1 = 'Visualization TileMap';
Expand Down