[test] Comment out Jest hooks in skipped blocks (#59086)

* [test] Comment out Jest hooks in skipped blocks

Jest will run the hooks regardless of if they are skipped.

Tests skipped in 61c9dc4022
and 420ded8eb2 were still resulting in build failures due to the beforeEach failing.

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Additional variables/imports no longer needed

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Skip additional flaky ingest tests

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Comment out file

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Must have one test

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
Tyler Smalley 2020-03-03 10:51:20 -08:00 committed by GitHub
parent b95abbae45
commit 2dcd3cc4c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 14 deletions

View file

@ -18,7 +18,7 @@
*/
import sinon from 'sinon';
import { sendRequest as sendRequestUnbound, useRequest as useRequestUnbound } from './request';
// import { sendRequest as sendRequestUnbound, useRequest as useRequestUnbound } from './request';
import React from 'react';
import { act } from 'react-dom/test-utils';
@ -52,6 +52,11 @@ describe.skip('request lib', () => {
let sendRequest;
let useRequest;
/**
*
* commented out due to hooks being called regardless of skip
* https://github.com/facebook/jest/issues/8379
beforeEach(() => {
sendPost = sinon.stub();
sendPost.withArgs(successRequest.path, successRequest.body).returns(successResponse);
@ -67,6 +72,8 @@ describe.skip('request lib', () => {
useRequest = useRequestUnbound.bind(null, httpClient);
});
*/
describe('sendRequest function', () => {
it('uses the provided path, method, and body to send the request', async () => {
const response = await sendRequest({ ...successRequest });

View file

@ -4,6 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/
test.skip('requires one test', () => {});
/**
* skipped due to all being flaky: https://github.com/elastic/kibana/issues/58954
*
* commented out due to hooks being called regardless of skip
* https://github.com/facebook/jest/issues/8379
import { resolve } from 'path';
import * as kbnTestServer from '../../../../../src/test_utils/kbn_server';
@ -23,8 +31,9 @@ function createXPackRoot(config: {} = {}) {
}
describe('ingestManager', () => {
describe.skip('default. manager, EPM, and Fleet all disabled', () => {
describe('default. manager, EPM, and Fleet all disabled', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
root = createXPackRoot();
await root.setup();
@ -50,8 +59,9 @@ describe('ingestManager', () => {
});
});
describe.skip('manager only (no EPM, no Fleet)', () => {
describe('manager only (no EPM, no Fleet)', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
const ingestManagerConfig = {
enabled: true,
@ -87,8 +97,9 @@ describe('ingestManager', () => {
// https://github.com/jfsiii/kibana/blob/f73b54ebb7e0f6fc00efd8a6800a01eb2d9fb772/x-pack/plugins/ingest_manager/server/plugin.ts#L84
// adding tests to confirm the Fleet & EPM routes are never added
describe.skip('manager and EPM; no Fleet', () => {
describe('manager and EPM; no Fleet', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
const ingestManagerConfig = {
enabled: true,
@ -122,6 +133,7 @@ describe('ingestManager', () => {
describe('manager and Fleet; no EPM)', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
const ingestManagerConfig = {
enabled: true,
@ -156,6 +168,7 @@ describe('ingestManager', () => {
describe('all flags enabled: manager, EPM, and Fleet)', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
beforeAll(async () => {
const ingestManagerConfig = {
enabled: true,
@ -188,3 +201,4 @@ describe('ingestManager', () => {
});
});
});
*/

View file

@ -6,22 +6,28 @@
jest.mock('ui/new_platform');
import { RemoteClusterForm } from '../../public/application/sections/components/remote_cluster_form';
import { pageHelpers, setupEnvironment, nextTick } from './helpers';
// import { pageHelpers, setupEnvironment, nextTick } from './helpers';
import { pageHelpers, nextTick } from './helpers';
import { REMOTE_CLUSTER_EDIT, REMOTE_CLUSTER_EDIT_NAME } from './helpers/constants';
const { setup } = pageHelpers.remoteClustersEdit;
// const { setup } = pageHelpers.remoteClustersEdit;
const { setup: setupRemoteClustersAdd } = pageHelpers.remoteClustersAdd;
// FLAKY: https://github.com/elastic/kibana/issues/57762
// FLAKY: https://github.com/elastic/kibana/issues/57997
// FLAKY: https://github.com/elastic/kibana/issues/57998
describe.skip('Edit Remote cluster', () => {
let server;
let httpRequestsMockHelpers;
// let server;
// let httpRequestsMockHelpers;
let component;
let find;
let exists;
/**
*
* commented out due to hooks being called regardless of skip
* https://github.com/facebook/jest/issues/8379
beforeAll(() => {
({ server, httpRequestsMockHelpers } = setupEnvironment());
});
@ -38,6 +44,8 @@ describe.skip('Edit Remote cluster', () => {
component.update();
});
*/
test('should have the title of the page set correctly', () => {
expect(exists('remoteClusterPageTitle')).toBe(true);
expect(find('remoteClusterPageTitle').text()).toEqual('Edit remote cluster');

View file

@ -41,12 +41,19 @@ describe.skip('onPostAuthInterceptor', () => {
).toString('base64')}`,
};
/**
*
* commented out due to hooks being called regardless of skip
* https://github.com/facebook/jest/issues/8379
beforeEach(async () => {
root = kbnTestServer.createRoot();
});
afterEach(async () => await root.shutdown());
*/
function initKbnServer(router: IRouter, basePath: IBasePath, routes: 'legacy' | 'new-platform') {
const kbnServer = kbnTestServer.getKbnServer(root);

View file

@ -22,12 +22,19 @@ import { elasticsearchServiceMock } from 'src/core/server/mocks';
describe.skip('onRequestInterceptor', () => {
let root: ReturnType<typeof kbnTestServer.createRoot>;
/**
*
* commented out due to hooks being called regardless of skip
* https://github.com/facebook/jest/issues/8379
beforeEach(async () => {
root = kbnTestServer.createRoot();
}, 30000);
afterEach(async () => await root.shutdown());
*/
function initKbnServer(router: IRouter, basePath: IBasePath, routes: 'legacy' | 'new-platform') {
const kbnServer = kbnTestServer.getKbnServer(root);

View file

@ -6,19 +6,25 @@
import Slapshot from '@mattapperson/slapshot';
import { createKibanaServer } from './servers';
import { getEsArchiver } from './services/es_archiver';
import { EsArchiver } from 'src/es_archiver';
import * as path from 'path';
// import { createKibanaServer } from './servers';
// import { getEsArchiver } from './services/es_archiver';
// import { EsArchiver } from 'src/es_archiver';
// import * as path from 'path';
import * as legacyElasticsearch from 'elasticsearch';
const { callWhenOnline, memorize } = Slapshot;
// const { callWhenOnline, memorize } = Slapshot;
const { memorize } = Slapshot;
let servers: { kbnServer: any; shutdown: () => void };
let esArchiver: EsArchiver;
// let esArchiver: EsArchiver;
// FLAKY: https://github.com/elastic/kibana/issues/44250
describe.skip('Example contract tests', () => {
/**
*
* commented out due to hooks being called regardless of skip
* https://github.com/facebook/jest/issues/8379
beforeAll(async () => {
await callWhenOnline(async () => {
servers = await createKibanaServer();
@ -28,6 +34,7 @@ describe.skip('Example contract tests', () => {
});
});
});
afterAll(async () => {
if (servers) {
await servers.shutdown();
@ -37,6 +44,8 @@ describe.skip('Example contract tests', () => {
beforeEach(async () => await callWhenOnline(() => esArchiver.load('example')));
afterEach(async () => await callWhenOnline(() => esArchiver.unload('example')));
*/
it('should run online or offline', async () => {
const res = await memorize('example_test_snapshot', async () => {
return { serverExists: !!servers.kbnServer };