mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
parent
b3363fba65
commit
4697b7efe1
53 changed files with 320 additions and 120 deletions
|
@ -60,7 +60,8 @@ export function runFtrCli() {
|
|||
include: toArray(flags['include-tag'] as string | string[]),
|
||||
exclude: toArray(flags['exclude-tag'] as string | string[]),
|
||||
},
|
||||
updateBaselines: flags.updateBaselines,
|
||||
updateBaselines: flags.updateBaselines || flags.u,
|
||||
updateSnapshots: flags.updateSnapshots || flags.u,
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -118,7 +119,7 @@ export function runFtrCli() {
|
|||
'exclude-tag',
|
||||
'kibana-install-dir',
|
||||
],
|
||||
boolean: ['bail', 'invert', 'test-stats', 'updateBaselines'],
|
||||
boolean: ['bail', 'invert', 'test-stats', 'updateBaselines', 'updateSnapshots', 'u'],
|
||||
default: {
|
||||
config: 'test/functional/config.js',
|
||||
},
|
||||
|
@ -133,6 +134,8 @@ export function runFtrCli() {
|
|||
--exclude-tag=tag a tag to be excluded, pass multiple times for multiple tags
|
||||
--test-stats print the number of tests (included and excluded) to STDERR
|
||||
--updateBaselines replace baseline screenshots with whatever is generated from the test
|
||||
--updateSnapshots replace inline and file snapshots with whatever is generated from the test
|
||||
-u replace both baseline screenshots and snapshots
|
||||
--kibana-install-dir directory where the Kibana install being tested resides
|
||||
`,
|
||||
},
|
||||
|
|
|
@ -28,10 +28,17 @@ import EventEmitter from 'events';
|
|||
export interface Suite {
|
||||
suites: Suite[];
|
||||
tests: Test[];
|
||||
title: string;
|
||||
file?: string;
|
||||
parent?: Suite;
|
||||
}
|
||||
|
||||
export interface Test {
|
||||
fullTitle(): string;
|
||||
title: string;
|
||||
file?: string;
|
||||
parent?: Suite;
|
||||
isPassed: () => boolean;
|
||||
}
|
||||
|
||||
export interface Runner extends EventEmitter {
|
||||
|
|
|
@ -138,7 +138,7 @@ export const schema = Joi.object()
|
|||
.default(),
|
||||
|
||||
updateBaselines: Joi.boolean().default(false),
|
||||
|
||||
updateSnapshots: Joi.boolean().default(false),
|
||||
browser: Joi.object()
|
||||
.keys({
|
||||
type: Joi.string().valid('chrome', 'firefox', 'msedge').default('chrome'),
|
||||
|
|
|
@ -21,6 +21,7 @@ import { isAbsolute } from 'path';
|
|||
|
||||
import { loadTracer } from '../load_tracer';
|
||||
import { decorateMochaUi } from './decorate_mocha_ui';
|
||||
import { decorateSnapshotUi } from '../snapshots/decorate_snapshot_ui';
|
||||
|
||||
/**
|
||||
* Load an array of test files into a mocha instance
|
||||
|
@ -31,7 +32,17 @@ import { decorateMochaUi } from './decorate_mocha_ui';
|
|||
* @param {String} path
|
||||
* @return {undefined} - mutates mocha, no return value
|
||||
*/
|
||||
export const loadTestFiles = ({ mocha, log, lifecycle, providers, paths, updateBaselines }) => {
|
||||
export const loadTestFiles = ({
|
||||
mocha,
|
||||
log,
|
||||
lifecycle,
|
||||
providers,
|
||||
paths,
|
||||
updateBaselines,
|
||||
updateSnapshots,
|
||||
}) => {
|
||||
decorateSnapshotUi(lifecycle, updateSnapshots);
|
||||
|
||||
const innerLoadTestFile = (path) => {
|
||||
if (typeof path !== 'string' || !isAbsolute(path)) {
|
||||
throw new TypeError('loadTestFile() only accepts absolute paths');
|
||||
|
|
|
@ -53,6 +53,7 @@ export async function setupMocha(lifecycle, log, config, providers) {
|
|||
providers,
|
||||
paths: config.get('testFiles'),
|
||||
updateBaselines: config.get('updateBaselines'),
|
||||
updateSnapshots: config.get('updateSnapshots'),
|
||||
});
|
||||
|
||||
// Each suite has a tag that is the path relative to the root of the repo
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { Test } from '../../fake_mocha_types';
|
||||
import { Lifecycle } from '../lifecycle';
|
||||
import { decorateSnapshotUi, expectSnapshot } from './decorate_snapshot_ui';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
describe('decorateSnapshotUi', () => {
|
||||
describe('when running a test', () => {
|
||||
let lifecycle: Lifecycle;
|
||||
beforeEach(() => {
|
||||
lifecycle = new Lifecycle();
|
||||
decorateSnapshotUi(lifecycle, false);
|
||||
});
|
||||
|
||||
it('passes when the snapshot matches the actual value', async () => {
|
||||
const test: Test = {
|
||||
title: 'Test',
|
||||
file: 'foo.ts',
|
||||
parent: {
|
||||
file: 'foo.ts',
|
||||
tests: [],
|
||||
suites: [],
|
||||
},
|
||||
} as any;
|
||||
|
||||
await lifecycle.beforeEachTest.trigger(test);
|
||||
|
||||
expect(() => {
|
||||
expectSnapshot('foo').toMatchInline(`"foo"`);
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws when the snapshot does not match the actual value', async () => {
|
||||
const test: Test = {
|
||||
title: 'Test',
|
||||
file: 'foo.ts',
|
||||
parent: {
|
||||
file: 'foo.ts',
|
||||
tests: [],
|
||||
suites: [],
|
||||
},
|
||||
} as any;
|
||||
|
||||
await lifecycle.beforeEachTest.trigger(test);
|
||||
|
||||
expect(() => {
|
||||
expectSnapshot('foo').toMatchInline(`"bar"`);
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
it('writes a snapshot to an external file if it does not exist', async () => {
|
||||
const test: Test = {
|
||||
title: 'Test',
|
||||
file: __filename,
|
||||
isPassed: () => true,
|
||||
} as any;
|
||||
|
||||
// @ts-expect-error
|
||||
test.parent = {
|
||||
file: __filename,
|
||||
tests: [test],
|
||||
suites: [],
|
||||
};
|
||||
|
||||
await lifecycle.beforeEachTest.trigger(test);
|
||||
|
||||
const snapshotFile = path.resolve(
|
||||
__dirname,
|
||||
'__snapshots__',
|
||||
'decorate_snapshot_ui.test.snap'
|
||||
);
|
||||
|
||||
expect(fs.existsSync(snapshotFile)).toBe(false);
|
||||
|
||||
expect(() => {
|
||||
expectSnapshot('foo').toMatch();
|
||||
}).not.toThrow();
|
||||
|
||||
await lifecycle.afterTestSuite.trigger(test.parent);
|
||||
|
||||
expect(fs.existsSync(snapshotFile)).toBe(true);
|
||||
|
||||
fs.unlinkSync(snapshotFile);
|
||||
|
||||
fs.rmdirSync(path.resolve(__dirname, '__snapshots__'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('when updating snapshots', () => {
|
||||
let lifecycle: Lifecycle;
|
||||
beforeEach(() => {
|
||||
lifecycle = new Lifecycle();
|
||||
decorateSnapshotUi(lifecycle, true);
|
||||
});
|
||||
|
||||
it("doesn't throw if the value does not match", async () => {
|
||||
const test: Test = {
|
||||
title: 'Test',
|
||||
file: 'foo.ts',
|
||||
parent: {
|
||||
file: 'foo.ts',
|
||||
tests: [],
|
||||
suites: [],
|
||||
},
|
||||
} as any;
|
||||
|
||||
await lifecycle.beforeEachTest.trigger(test);
|
||||
|
||||
expect(() => {
|
||||
expectSnapshot('bar').toMatchInline(`"foo"`);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,7 +1,20 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
|
@ -14,8 +27,9 @@ import path from 'path';
|
|||
import expect from '@kbn/expect';
|
||||
import prettier from 'prettier';
|
||||
import babelTraverse from '@babel/traverse';
|
||||
import { Suite, Test } from 'mocha';
|
||||
import { flatten } from 'lodash';
|
||||
import { flatten, once } from 'lodash';
|
||||
import { Lifecycle } from '../lifecycle';
|
||||
import { Test, Suite } from '../../fake_mocha_types';
|
||||
|
||||
type ISnapshotState = InstanceType<typeof SnapshotState>;
|
||||
|
||||
|
@ -59,12 +73,38 @@ function getSnapshotMeta(currentTest: Test) {
|
|||
};
|
||||
}
|
||||
|
||||
export function registerMochaHooksForSnapshots() {
|
||||
const modifyStackTracePrepareOnce = once(() => {
|
||||
const originalPrepareStackTrace = Error.prepareStackTrace;
|
||||
|
||||
// jest-snapshot uses a stack trace to determine which file/line/column
|
||||
// an inline snapshot should be written to. We filter out match_snapshot
|
||||
// from the stack trace to prevent it from wanting to write to this file.
|
||||
|
||||
Error.prepareStackTrace = (error, structuredStackTrace) => {
|
||||
let filteredStrackTrace: NodeJS.CallSite[] = structuredStackTrace;
|
||||
if (registered) {
|
||||
filteredStrackTrace = filteredStrackTrace.filter((callSite) => {
|
||||
// check for both compiled and uncompiled files
|
||||
return !callSite.getFileName()?.match(/decorate_snapshot_ui\.(js|ts)/);
|
||||
});
|
||||
}
|
||||
|
||||
if (originalPrepareStackTrace) {
|
||||
return originalPrepareStackTrace(error, filteredStrackTrace);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
export function decorateSnapshotUi(lifecycle: Lifecycle, updateSnapshots: boolean) {
|
||||
let snapshotStatesByFilePath: Record<
|
||||
string,
|
||||
{ snapshotState: ISnapshotState; testsInFile: Test[] }
|
||||
> = {};
|
||||
|
||||
registered = true;
|
||||
|
||||
modifyStackTracePrepareOnce();
|
||||
|
||||
addSerializer({
|
||||
serialize: (num: number) => {
|
||||
return String(parseFloat(num.toPrecision(15)));
|
||||
|
@ -74,15 +114,14 @@ export function registerMochaHooksForSnapshots() {
|
|||
},
|
||||
});
|
||||
|
||||
registered = true;
|
||||
|
||||
beforeEach(function () {
|
||||
const currentTest = this.currentTest!;
|
||||
// @ts-expect-error
|
||||
global.expectSnapshot = expectSnapshot;
|
||||
|
||||
lifecycle.beforeEachTest.add((currentTest: Test) => {
|
||||
const { file, snapshotTitle } = getSnapshotMeta(currentTest);
|
||||
|
||||
if (!snapshotStatesByFilePath[file]) {
|
||||
snapshotStatesByFilePath[file] = getSnapshotState(file, currentTest);
|
||||
snapshotStatesByFilePath[file] = getSnapshotState(file, currentTest, updateSnapshots);
|
||||
}
|
||||
|
||||
testContext = {
|
||||
|
@ -95,17 +134,14 @@ export function registerMochaHooksForSnapshots() {
|
|||
};
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
testContext = null;
|
||||
});
|
||||
|
||||
after(function () {
|
||||
// save snapshot after tests complete
|
||||
lifecycle.afterTestSuite.add(function (testSuite) {
|
||||
// save snapshot & check unused after top-level test suite completes
|
||||
if (testSuite.parent?.parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unused: string[] = [];
|
||||
|
||||
const isUpdatingSnapshots = process.env.UPDATE_SNAPSHOTS;
|
||||
|
||||
Object.keys(snapshotStatesByFilePath).forEach((file) => {
|
||||
const { snapshotState, testsInFile } = snapshotStatesByFilePath[file];
|
||||
|
||||
|
@ -118,7 +154,7 @@ export function registerMochaHooksForSnapshots() {
|
|||
}
|
||||
});
|
||||
|
||||
if (!isUpdatingSnapshots) {
|
||||
if (!updateSnapshots) {
|
||||
unused.push(...snapshotState.getUncheckedKeys());
|
||||
} else {
|
||||
snapshotState.removeUncheckedKeys();
|
||||
|
@ -131,36 +167,19 @@ export function registerMochaHooksForSnapshots() {
|
|||
throw new Error(
|
||||
`${unused.length} obsolete snapshot(s) found:\n${unused.join(
|
||||
'\n\t'
|
||||
)}.\n\nRun tests again with \`UPDATE_SNAPSHOTS=1\` to remove them.`
|
||||
)}.\n\nRun tests again with \`--updateSnapshots\` to remove them.`
|
||||
);
|
||||
}
|
||||
|
||||
snapshotStatesByFilePath = {};
|
||||
|
||||
registered = false;
|
||||
});
|
||||
}
|
||||
|
||||
const originalPrepareStackTrace = Error.prepareStackTrace;
|
||||
|
||||
// jest-snapshot uses a stack trace to determine which file/line/column
|
||||
// an inline snapshot should be written to. We filter out match_snapshot
|
||||
// from the stack trace to prevent it from wanting to write to this file.
|
||||
|
||||
Error.prepareStackTrace = (error, structuredStackTrace) => {
|
||||
const filteredStrackTrace = structuredStackTrace.filter((callSite) => {
|
||||
return !callSite.getFileName()?.endsWith('match_snapshot.ts');
|
||||
});
|
||||
if (originalPrepareStackTrace) {
|
||||
return originalPrepareStackTrace(error, filteredStrackTrace);
|
||||
}
|
||||
};
|
||||
|
||||
function recursivelyGetTestsFromSuite(suite: Suite): Test[] {
|
||||
return suite.tests.concat(flatten(suite.suites.map((s) => recursivelyGetTestsFromSuite(s))));
|
||||
}
|
||||
|
||||
function getSnapshotState(file: string, test: Test) {
|
||||
function getSnapshotState(file: string, test: Test, updateSnapshots: boolean) {
|
||||
const dirname = path.dirname(file);
|
||||
const filename = path.basename(file);
|
||||
|
||||
|
@ -177,7 +196,7 @@ function getSnapshotState(file: string, test: Test) {
|
|||
const snapshotState = new SnapshotState(
|
||||
path.join(dirname + `/__snapshots__/` + filename.replace(path.extname(filename), '.snap')),
|
||||
{
|
||||
updateSnapshot: process.env.UPDATE_SNAPSHOTS ? 'all' : 'new',
|
||||
updateSnapshot: updateSnapshots ? 'all' : 'new',
|
||||
getPrettier: () => prettier,
|
||||
getBabelTraverse: () => babelTraverse,
|
||||
}
|
|
@ -16,6 +16,8 @@ Options:
|
|||
--bail Stop the test run at the first failure.
|
||||
--grep <pattern> Pattern to select which tests to run.
|
||||
--updateBaselines Replace baseline screenshots with whatever is generated from the test.
|
||||
--updateSnapshots Replace inline and file snapshots with whatever is generated from the test.
|
||||
--u Replace both baseline screenshots and snapshots
|
||||
--include <file> Files that must included to be run, can be included multiple times.
|
||||
--exclude <file> Files that must NOT be included to be run, can be included multiple times.
|
||||
--include-tag <tag> Tags that suites must include to be run, can be included multiple times.
|
||||
|
@ -48,6 +50,27 @@ Object {
|
|||
}
|
||||
`;
|
||||
|
||||
exports[`process options for run tests CLI accepts boolean value for updateSnapshots 1`] = `
|
||||
Object {
|
||||
"assertNoneExcluded": false,
|
||||
"configs": Array [
|
||||
<absolute path>/foo,
|
||||
],
|
||||
"createLogger": [Function],
|
||||
"esFrom": "snapshot",
|
||||
"extraKbnOpts": undefined,
|
||||
"suiteFiles": Object {
|
||||
"exclude": Array [],
|
||||
"include": Array [],
|
||||
},
|
||||
"suiteTags": Object {
|
||||
"exclude": Array [],
|
||||
"include": Array [],
|
||||
},
|
||||
"updateSnapshots": true,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`process options for run tests CLI accepts debug option 1`] = `
|
||||
Object {
|
||||
"assertNoneExcluded": false,
|
||||
|
|
|
@ -16,6 +16,8 @@ Options:
|
|||
--bail Stop the test run at the first failure.
|
||||
--grep <pattern> Pattern to select which tests to run.
|
||||
--updateBaselines Replace baseline screenshots with whatever is generated from the test.
|
||||
--updateSnapshots Replace inline and file snapshots with whatever is generated from the test.
|
||||
--u Replace both baseline screenshots and snapshots
|
||||
--include <file> Files that must included to be run, can be included multiple times.
|
||||
--exclude <file> Files that must NOT be included to be run, can be included multiple times.
|
||||
--include-tag <tag> Tags that suites must include to be run, can be included multiple times.
|
||||
|
|
|
@ -46,6 +46,12 @@ const options = {
|
|||
updateBaselines: {
|
||||
desc: 'Replace baseline screenshots with whatever is generated from the test.',
|
||||
},
|
||||
updateSnapshots: {
|
||||
desc: 'Replace inline and file snapshots with whatever is generated from the test.',
|
||||
},
|
||||
u: {
|
||||
desc: 'Replace both baseline screenshots and snapshots',
|
||||
},
|
||||
include: {
|
||||
arg: '<file>',
|
||||
desc: 'Files that must included to be run, can be included multiple times.',
|
||||
|
|
|
@ -76,6 +76,11 @@ describe('process options for run tests CLI', () => {
|
|||
expect(options).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('accepts boolean value for updateSnapshots', () => {
|
||||
const options = processOptions({ updateSnapshots: true }, ['foo']);
|
||||
expect(options).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('accepts source value for esFrom', () => {
|
||||
const options = processOptions({ esFrom: 'source' }, ['foo']);
|
||||
expect(options).toMatchSnapshot();
|
||||
|
|
|
@ -125,6 +125,22 @@ describe('run tests CLI', () => {
|
|||
expect(exitMock).not.toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('accepts boolean value for updateSnapshots', async () => {
|
||||
global.process.argv.push('--updateSnapshots');
|
||||
|
||||
await runTestsCli(['foo']);
|
||||
|
||||
expect(exitMock).not.toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('accepts boolean value for -u', async () => {
|
||||
global.process.argv.push('-u');
|
||||
|
||||
await runTestsCli(['foo']);
|
||||
|
||||
expect(exitMock).not.toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('accepts source value for esFrom', async () => {
|
||||
global.process.argv.push('--esFrom', 'source');
|
||||
|
||||
|
|
|
@ -7,6 +7,13 @@ exports[`start servers CLI options accepts boolean value for updateBaselines 1`]
|
|||
"
|
||||
`;
|
||||
|
||||
exports[`start servers CLI options accepts boolean value for updateSnapshots 1`] = `
|
||||
"
|
||||
[31mfunctional_tests_server: invalid option [updateSnapshots][39m
|
||||
...stack trace...
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`start servers CLI options rejects bail 1`] = `
|
||||
"
|
||||
[31mfunctional_tests_server: invalid option [bail][39m
|
||||
|
@ -40,4 +47,4 @@ exports[`start servers CLI options rejects invalid options even if valid options
|
|||
[31mfunctional_tests_server: invalid option [grep][39m
|
||||
...stack trace...
|
||||
"
|
||||
`;
|
||||
`;
|
||||
|
|
|
@ -126,6 +126,15 @@ describe('start servers CLI', () => {
|
|||
checkMockConsoleLogSnapshot(logMock);
|
||||
});
|
||||
|
||||
it('accepts boolean value for updateSnapshots', async () => {
|
||||
global.process.argv.push('--updateSnapshots');
|
||||
|
||||
await startServersCli('foo');
|
||||
|
||||
expect(exitMock).toHaveBeenCalledWith(1);
|
||||
checkMockConsoleLogSnapshot(logMock);
|
||||
});
|
||||
|
||||
it('accepts source value for esFrom', async () => {
|
||||
global.process.argv.push('--esFrom', 'source');
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CliError } from './run_cli';
|
|||
|
||||
async function createFtr({
|
||||
configPath,
|
||||
options: { installDir, log, bail, grep, updateBaselines, suiteFiles, suiteTags },
|
||||
options: { installDir, log, bail, grep, updateBaselines, suiteFiles, suiteTags, updateSnapshots },
|
||||
}) {
|
||||
const config = await readConfigFile(log, configPath);
|
||||
|
||||
|
@ -37,6 +37,7 @@ async function createFtr({
|
|||
installDir,
|
||||
},
|
||||
updateBaselines,
|
||||
updateSnapshots,
|
||||
suiteFiles: {
|
||||
include: [...suiteFiles.include, ...config.get('suiteFiles.include')],
|
||||
exclude: [...suiteFiles.exclude, ...config.get('suiteFiles.exclude')],
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
"src/**/*",
|
||||
"index.d.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"types/ftr_globals/**/*"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
|
|
|
@ -19,27 +19,11 @@
|
|||
|
||||
import { Suite } from 'mocha';
|
||||
|
||||
type Tags =
|
||||
| 'ciGroup1'
|
||||
| 'ciGroup2'
|
||||
| 'ciGroup3'
|
||||
| 'ciGroup4'
|
||||
| 'ciGroup5'
|
||||
| 'ciGroup6'
|
||||
| 'ciGroup7'
|
||||
| 'ciGroup8'
|
||||
| 'ciGroup9'
|
||||
| 'ciGroup10'
|
||||
| 'ciGroup11'
|
||||
| 'ciGroup12';
|
||||
|
||||
// We need to use the namespace here to match the Mocha definition
|
||||
declare module 'mocha' {
|
||||
interface Suite {
|
||||
/**
|
||||
* Assign tags to the test suite to determine in which CI job it should be run.
|
||||
*/
|
||||
tags<T extends Tags>(tags: T | T[]): void;
|
||||
tags<T extends string>(tags: T | T[]): void;
|
||||
tags(tags: string[] | string): void;
|
||||
}
|
||||
}
|
25
packages/kbn-test/types/ftr_globals/snapshots.d.ts
vendored
Normal file
25
packages/kbn-test/types/ftr_globals/snapshots.d.ts
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
declare const expectSnapshot: (
|
||||
received: any
|
||||
) => {
|
||||
toMatch: () => void;
|
||||
toMatchInline: (_actual?: any) => void;
|
||||
};
|
|
@ -4,7 +4,7 @@
|
|||
"incremental": false,
|
||||
"types": ["node", "mocha", "flot"]
|
||||
},
|
||||
"include": ["**/*", "../typings/elastic__node_crypto.d.ts", "typings/**/*"],
|
||||
"include": ["**/*", "../typings/elastic__node_crypto.d.ts", "typings/**/*", "../packages/kbn-test/types/ftr_globals/**/*"],
|
||||
"exclude": ["plugin_functional/plugins/**/*", "interpreter_functional/plugins/**/*"],
|
||||
"references": [
|
||||
{ "path": "../src/core/tsconfig.json" },
|
||||
|
|
|
@ -9,15 +9,12 @@ import {
|
|||
settingsObjectId,
|
||||
settingsObjectType,
|
||||
} from '../../../../../plugins/uptime/server/lib/saved_objects';
|
||||
import { registerMochaHooksForSnapshots } from '../../../../apm_api_integration/common/match_snapshot';
|
||||
|
||||
export default function ({ getService, loadTestFile }: FtrProviderContext) {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const server = getService('kibanaServer');
|
||||
|
||||
describe('uptime REST endpoints', () => {
|
||||
registerMochaHooksForSnapshots();
|
||||
|
||||
beforeEach('clear settings', async () => {
|
||||
try {
|
||||
await server.savedObjects.delete({
|
||||
|
|
|
@ -9,7 +9,6 @@ import { isRight } from 'fp-ts/lib/Either';
|
|||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
import { MonitorSummariesResultType } from '../../../../../plugins/uptime/common/runtime_types';
|
||||
import { API_URLS } from '../../../../../plugins/uptime/common/constants';
|
||||
import { expectSnapshot } from '../../../../apm_api_integration/common/match_snapshot';
|
||||
|
||||
interface ExpectedMonitorStatesPage {
|
||||
response: any;
|
||||
|
|
|
@ -9,7 +9,6 @@ import { format } from 'url';
|
|||
import { PromiseReturnType } from '../../../../../plugins/observability/typings/common';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
|
|
@ -9,7 +9,6 @@ import { format } from 'url';
|
|||
import { PromiseReturnType } from '../../../../../plugins/observability/typings/common';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
|
|
@ -4,12 +4,9 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { FtrProviderContext } from '../../common/ftr_provider_context';
|
||||
import { registerMochaHooksForSnapshots } from '../../common/match_snapshot';
|
||||
|
||||
export default function apmApiIntegrationTests({ loadTestFile }: FtrProviderContext) {
|
||||
describe('APM specs (basic)', function () {
|
||||
registerMochaHooksForSnapshots();
|
||||
|
||||
this.tags('ciGroup1');
|
||||
|
||||
loadTestFile(require.resolve('./feature_controls'));
|
||||
|
|
|
@ -8,7 +8,6 @@ import { first } from 'lodash';
|
|||
import { MetricsChartsByAgentAPIResponse } from '../../../../../plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent';
|
||||
import { GenericMetricsChart } from '../../../../../plugins/apm/server/lib/metrics/transform_metrics_chart';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
|
||||
interface ChartResponse {
|
||||
body: MetricsChartsByAgentAPIResponse;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
import expect from '@kbn/expect';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import expect from '@kbn/expect';
|
||||
import qs from 'querystring';
|
||||
import { pick, uniqBy } from 'lodash';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
import archives from '../../../common/archives_metadata';
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { isEmpty, pick } from 'lodash';
|
||||
import { PromiseReturnType } from '../../../../../plugins/observability/typings/common';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
import expect from '@kbn/expect';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
import expect from '@kbn/expect';
|
||||
import { omit, orderBy } from 'lodash';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { AgentConfigurationIntake } from '../../../../../plugins/apm/common/agent_configuration/configuration_types';
|
||||
import { AgentConfigSearchParams } from '../../../../../plugins/apm/server/routes/settings/agent_configuration';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
export default function apiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
export default function apiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { CustomLink } from '../../../../../plugins/apm/common/custom_link/custom_link_types';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { sortBy } from 'lodash';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
import expect from '@kbn/expect';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -7,7 +7,6 @@ import expect from '@kbn/expect';
|
|||
import qs from 'querystring';
|
||||
import { isEmpty } from 'lodash';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { first, last } from 'lodash';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { sortBy } from 'lodash';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
function sortTransactionGroups(items: any[]) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import expect from '@kbn/expect';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { PromiseReturnType } from '../../../../../plugins/observability/typings/common';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
export default function ApiTest({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function rumServicesApiTests({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function rumHasDataApiTests({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function rumJsErrorsApiTests({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function rumServicesApiTests({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function rumServicesApiTests({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function rumServicesApiTests({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function rumServicesApiTests({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,14 +5,11 @@
|
|||
*/
|
||||
|
||||
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
|
||||
import { registerMochaHooksForSnapshots } from '../../common/match_snapshot';
|
||||
|
||||
export default function observabilityApiIntegrationTests({ loadTestFile }: FtrProviderContext) {
|
||||
describe('APM specs (trial)', function () {
|
||||
this.tags('ciGroup1');
|
||||
|
||||
registerMochaHooksForSnapshots();
|
||||
|
||||
describe('Services', function () {
|
||||
loadTestFile(require.resolve('./services/annotations'));
|
||||
loadTestFile(require.resolve('./services/top_services.ts'));
|
||||
|
|
|
@ -9,7 +9,6 @@ import expect from '@kbn/expect';
|
|||
import { isEmpty, uniq } from 'lodash';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
import { PromiseReturnType } from '../../../../../plugins/observability/typings/common';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
export default function serviceMapsApiTests({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { PromiseReturnType } from '../../../../../plugins/observability/typings/common';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { expectSnapshot } from '../../../common/match_snapshot';
|
||||
import { PromiseReturnType } from '../../../../../plugins/observability/typings/common';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
import archives_metadata from '../../../common/archives_metadata';
|
||||
|
|
17
x-pack/test/mocha_decorations.d.ts
vendored
17
x-pack/test/mocha_decorations.d.ts
vendored
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { Suite } from 'mocha';
|
||||
|
||||
// We need to use the namespace here to match the Mocha definition
|
||||
declare module 'mocha' {
|
||||
interface Suite {
|
||||
/**
|
||||
* Assign tags to the test suite to determine in which CI job it should be run.
|
||||
*/
|
||||
tags(tags: string[] | string): void;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
"incremental": false,
|
||||
"types": ["mocha", "node", "flot"]
|
||||
},
|
||||
"include": ["**/*", "../typings/**/*"],
|
||||
"include": ["**/*", "../typings/**/*", "../../packages/kbn-test/types/ftr_globals/**/*"],
|
||||
"exclude": ["../typings/jest.d.ts"],
|
||||
"references": [
|
||||
{ "path": "../../src/core/tsconfig.json" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue