-
Notifications
You must be signed in to change notification settings - Fork 113
/
configuration.ts
50 lines (40 loc) · 1.28 KB
/
configuration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import type { IJestLike } from './feature-definition-creation';
export type ErrorOptions = {
scenariosMustMatchFeatureFile: boolean;
stepsMustMatchFeatureFile: boolean;
allowScenariosNotInFeatureFile: boolean;
};
export type Options = {
loadRelativePath?: boolean;
tagFilter?: string;
errors?: ErrorOptions | boolean;
scenarioNameTemplate?: (vars: ScenarioNameTemplateVars) => string;
runner?: IJestLike;
};
export type ScenarioNameTemplateVars = {
featureTitle: string;
scenarioTitle: string;
scenarioTags: string[];
featureTags: string[];
};
export const defaultErrorSettings = {
scenariosMustMatchFeatureFile: true,
stepsMustMatchFeatureFile: true,
allowScenariosNotInFeatureFile: false,
};
export const defaultConfiguration: Options = {
tagFilter: undefined,
scenarioNameTemplate: undefined,
errors: defaultErrorSettings,
};
let globalConfiguration: Options = {} as Options;
export const getJestCucumberConfiguration = (options?: Options) => {
const mergedOptions = { ...defaultConfiguration, ...globalConfiguration, ...(options || {}) };
if (mergedOptions.errors === true) {
mergedOptions.errors = defaultErrorSettings;
}
return mergedOptions;
};
export const setJestCucumberConfiguration = (options: Options) => {
globalConfiguration = options;
};