[APM] Add skip() method to registry.when (#89572)

Closes #89431.
This commit is contained in:
Dario Gieselaar 2021-01-28 17:43:51 +01:00 committed by GitHub
parent 80b720da11
commit cd9c79bec0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,17 +36,12 @@ let configName: APMFtrConfigName | undefined;
let running: boolean = false;
export const registry = {
init: (config: APMFtrConfigName) => {
configName = config;
callbacks.length = 0;
running = false;
},
when: (
function when(
title: string,
conditions: RunCondition | RunCondition[],
callback: (condition: RunCondition) => void
) => {
callback: (condition: RunCondition) => void,
skip?: boolean
) {
const allConditions = castArray(conditions);
if (!allConditions.length) {
@ -71,9 +66,12 @@ export const registry = {
runs: [
{
cb: () => {
const suite = describe(title, () => {
const suite: ReturnType<typeof describe> = (skip ? describe.skip : describe)(
title,
() => {
callback(matchedCondition);
});
}
) as any;
suite.file = file;
suite.eachTest((test) => {
@ -84,7 +82,23 @@ export const registry = {
],
});
});
}
when.skip = (
title: string,
conditions: RunCondition | RunCondition[],
callback: (condition: RunCondition) => void
) => {
when(title, conditions, callback, true);
};
export const registry = {
init: (config: APMFtrConfigName) => {
configName = config;
callbacks.length = 0;
running = false;
},
when,
run: (context: FtrProviderContext) => {
if (!configName) {
throw new Error(`registry was not init() before running`);