@autometa/executor 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,138 @@
1
+ import type { HookType, ParameterRegistryLike, ScopeExecutionAdapter, ScopeKind, ScopeNode, StepDefinition } from "@autometa/scopes";
2
+ import type { SimpleStep } from "@autometa/gherkin";
3
+ import type { SimplePickle } from "@autometa/gherkin";
4
+ import type { ScenarioExecution } from "@autometa/test-builder";
5
+ import { type HookCollection, type ResolvedHook } from "./hooks";
6
+ import type { ExecutorRuntime } from "./types";
7
+ export type StepStatus = "passed" | "failed" | "skipped";
8
+ export interface HookLifecycleTargetScopeMetadata {
9
+ readonly id: string;
10
+ readonly kind: ScopeKind;
11
+ readonly name?: string;
12
+ }
13
+ type ScenarioLifecycleType = ScenarioExecution<unknown>["type"];
14
+ export interface HookLifecycleScenarioMetadata {
15
+ readonly id: string;
16
+ readonly name: string;
17
+ readonly type: ScenarioLifecycleType;
18
+ readonly tags: readonly string[];
19
+ readonly qualifiedName: string;
20
+ }
21
+ export interface HookLifecycleStepMetadata {
22
+ readonly index: number;
23
+ readonly keyword?: string;
24
+ readonly text?: string;
25
+ readonly status?: StepStatus;
26
+ }
27
+ export interface HookLifecycleMetadata {
28
+ readonly targetScope: HookLifecycleTargetScopeMetadata;
29
+ readonly scenario?: HookLifecycleScenarioMetadata;
30
+ readonly step?: HookLifecycleStepMetadata;
31
+ readonly hook?: unknown;
32
+ readonly [key: string]: unknown;
33
+ }
34
+ export interface StepHookDetails<World> {
35
+ readonly index: number;
36
+ readonly definition?: StepDefinition<World>;
37
+ readonly gherkin?: SimpleStep;
38
+ readonly status?: StepStatus;
39
+ }
40
+ export interface StepHookInvocationOptions<World> {
41
+ readonly direction?: HookDirection;
42
+ readonly step?: StepHookDetails<World>;
43
+ readonly metadata?: Record<string, unknown>;
44
+ }
45
+ export type HookInvoker<World> = (hooks: readonly ResolvedHook<World>[], options: StepHookInvocationOptions<World>) => Promise<void>;
46
+ export interface HookLogPathSegment {
47
+ readonly id: string;
48
+ readonly kind: ScopeKind | "step";
49
+ readonly name: string;
50
+ readonly keyword?: string;
51
+ }
52
+ export interface HookLogStepDetails {
53
+ readonly index: number;
54
+ readonly keyword?: string;
55
+ readonly text?: string;
56
+ readonly status?: StepStatus;
57
+ }
58
+ export interface HookLogScenarioDetails {
59
+ readonly id: string;
60
+ readonly name: string;
61
+ readonly fullName: string;
62
+ readonly keyword?: string;
63
+ readonly language?: string;
64
+ }
65
+ export type HookLogPhase = "before" | "after";
66
+ export interface HookLogEvent {
67
+ readonly message: string;
68
+ readonly hookId: string;
69
+ readonly hookType: HookType;
70
+ readonly hookDescription?: string;
71
+ readonly phase: HookLogPhase;
72
+ readonly path: readonly HookLogPathSegment[];
73
+ readonly scenario?: HookLogScenarioDetails;
74
+ readonly step?: HookLogStepDetails;
75
+ readonly targetKeyword?: string;
76
+ readonly language?: string;
77
+ }
78
+ export type HookLogListener = (event: HookLogEvent) => void;
79
+ export interface ScopeLifecycleOptions {
80
+ readonly hookLogger?: HookLogListener;
81
+ readonly featureLanguage?: string;
82
+ readonly scopeKeywords?: ReadonlyMap<string, string>;
83
+ }
84
+ export interface ScenarioEventContext {
85
+ readonly pickle: SimplePickle;
86
+ }
87
+ export interface ScenarioRunContext<World> {
88
+ readonly world: World;
89
+ readonly parameterRegistry: ParameterRegistryLike | undefined;
90
+ readonly beforeStepHooks: readonly ResolvedHook<World>[];
91
+ readonly afterStepHooks: readonly ResolvedHook<World>[];
92
+ readonly events?: ScenarioEventContext;
93
+ invokeHooks: HookInvoker<World>;
94
+ }
95
+ type HookDirection = "asc" | "desc";
96
+ export declare class ScopeLifecycle<World> {
97
+ private readonly adapter;
98
+ private readonly states;
99
+ private readonly depthMap;
100
+ private readonly root;
101
+ private readonly hookLogger?;
102
+ private readonly featureLanguage;
103
+ private readonly scopeKeywords;
104
+ constructor(adapter: ScopeExecutionAdapter<World>, options?: ScopeLifecycleOptions);
105
+ configurePersistentScope(scope: ScopeNode<World>, runtime: ExecutorRuntime): void;
106
+ collectScenarioHooks(execution: ScenarioExecution<World>): HookCollection<World>;
107
+ runScenario(execution: ScenarioExecution<World>, hooks: HookCollection<World>, runner: (world: World, context: ScenarioRunContext<World>) => Promise<void>, options?: {
108
+ readonly events?: ScenarioEventContext;
109
+ }): Promise<void>;
110
+ private ensureState;
111
+ private teardownState;
112
+ private ensureAncestorStates;
113
+ private resolveParentWorld;
114
+ private resolveParentWorldForScenario;
115
+ private getParentScope;
116
+ private isPersistentScope;
117
+ private shouldMaterializePersistentScope;
118
+ private runScopeHooks;
119
+ private createHookInvoker;
120
+ private invokeHooks;
121
+ private buildHookMetadata;
122
+ private collectHooksForScope;
123
+ private buildChain;
124
+ private createContextLogger;
125
+ private buildHookLogEvent;
126
+ private toPathSegment;
127
+ private toStepSegment;
128
+ private toStepDetails;
129
+ private describeStep;
130
+ private describeStepExpression;
131
+ private findScenarioSegmentIndex;
132
+ private buildScenarioDetails;
133
+ private resolveLanguage;
134
+ private sortHooks;
135
+ private compareHooks;
136
+ private buildDepthMap;
137
+ }
138
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface TagFilter {
2
+ evaluate(tags: readonly string[]): boolean;
3
+ }
4
+ export declare const createTagFilter: (expression: string | undefined) => TagFilter;
@@ -0,0 +1,9 @@
1
+ import type { ExecutorConfig } from "@autometa/config";
2
+ import type { TimeoutSpec } from "@autometa/scopes";
3
+ export type TimeoutSource = "scenario" | "hook" | "config" | "default";
4
+ export interface TimeoutResolution {
5
+ milliseconds: number | undefined;
6
+ source: TimeoutSource;
7
+ }
8
+ export declare const resolveTimeout: (explicit: TimeoutSpec | undefined, config: ExecutorConfig, explicitSource?: TimeoutSource) => TimeoutResolution;
9
+ export declare const chooseTimeout: (primary: TimeoutSpec | undefined, secondary: TimeoutSpec | undefined, config: ExecutorConfig) => TimeoutResolution;
@@ -0,0 +1,31 @@
1
+ export type HookHandler = () => void | Promise<void>;
2
+ export type SuiteFn = {
3
+ (title: string, handler: () => void, timeout?: number): void;
4
+ skip: SuiteFn;
5
+ only: SuiteFn;
6
+ concurrent?: SuiteFn;
7
+ sequential?: SuiteFn;
8
+ };
9
+ export type TestFn = {
10
+ (title: string, handler: () => void | Promise<void>, timeout?: number): void;
11
+ skip: TestFn;
12
+ only: TestFn;
13
+ concurrent?: TestFn;
14
+ sequential?: TestFn;
15
+ failing?: TestFn;
16
+ fails?: TestFn;
17
+ todo?: (title: string, reason?: string) => void;
18
+ pending?: (title: string, reason?: string) => void;
19
+ };
20
+ export interface ExecutorRuntime {
21
+ suite: SuiteFn;
22
+ test: TestFn;
23
+ beforeAll(handler: HookHandler, timeout?: number): void;
24
+ afterAll(handler: HookHandler, timeout?: number): void;
25
+ beforeEach(handler: HookHandler, timeout?: number): void;
26
+ afterEach(handler: HookHandler, timeout?: number): void;
27
+ currentTestName(): string | undefined;
28
+ retry?(count: number): void;
29
+ warn?(message: string): void;
30
+ logError?(error: Error): void;
31
+ }
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@autometa/executor",
3
+ "version": "1.0.0-rc.0",
4
+ "description": "",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs",
15
+ "default": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
17
+ },
18
+ "dependencies": {
19
+ "@cucumber/cucumber-expressions": "^16.1.2",
20
+ "@cucumber/tag-expressions": "^5.0.1",
21
+ "@autometa/events": "1.0.0-rc.0",
22
+ "@autometa/gherkin": "1.0.0-rc.0",
23
+ "@autometa/errors": "1.0.0-rc.0",
24
+ "@autometa/config": "1.0.0-rc.0",
25
+ "@autometa/scopes": "1.0.0-rc.0",
26
+ "@autometa/test-builder": "1.0.0-rc.0"
27
+ },
28
+ "license": "MIT",
29
+ "devDependencies": {
30
+ "@types/node": "^18.11.18",
31
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
32
+ "@typescript-eslint/parser": "^5.54.1",
33
+ "eslint": "^8.37.0",
34
+ "eslint-config-prettier": "^8.3.0",
35
+ "rimraf": "^4.1.2",
36
+ "tsup": "^7.2.0",
37
+ "typescript": "^4.9.5",
38
+ "vitest": "1.4.0",
39
+ "eslint-config-custom": "0.6.0",
40
+ "tsconfig": "0.7.0",
41
+ "tsup-config": "0.1.0"
42
+ },
43
+ "scripts": {
44
+ "type-check": "tsc --noEmit -p tsconfig.dev.json",
45
+ "type-check:watch": "tsc --noEmit --watch -p tsconfig.dev.json",
46
+ "build": "tsup && pnpm run build:types",
47
+ "build:types": "rimraf tsconfig.types.tsbuildinfo && tsc --build tsconfig.types.json",
48
+ "build:watch": "tsup --watch",
49
+ "dev": "tsup --watch",
50
+ "test": "vitest run --passWithNoTests",
51
+ "test:watch": "vitest --passWithNoTests",
52
+ "test:ui": "vitest --ui --passWithNoTests",
53
+ "coverage": "vitest run --coverage --passWithNoTests",
54
+ "lint": "eslint . --max-warnings 0",
55
+ "lint:fix": "eslint . --fix",
56
+ "prettify": "prettier --config .prettierrc 'src/**/*.ts' --write",
57
+ "clean": "rimraf dist"
58
+ }
59
+ }