@autometa/runner 0.6.3 → 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.
- package/README.md +2 -121
- package/dist/bindings/create-bindings-ts.d.ts +46 -0
- package/dist/bindings/index.d.ts +1 -0
- package/dist/builder/create-runner-builder.d.ts +149 -0
- package/dist/core/parameter-registry.d.ts +16 -0
- package/dist/core/runner-context.d.ts +27 -0
- package/dist/cucumber-runner.d.ts +9 -0
- package/dist/current.d.ts +5 -0
- package/dist/decorators/create-runner-decorators.d.ts +55 -0
- package/dist/dsl/create-decorator-runner.d.ts +19 -0
- package/dist/dsl/create-global-runner.d.ts +9 -0
- package/dist/dsl/create-runner.d.ts +82 -0
- package/dist/dsl/decorator-shared.d.ts +12 -0
- package/dist/global.d.ts +14 -0
- package/dist/index.cjs +2212 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +22 -674
- package/dist/index.js +2064 -456
- package/dist/index.js.map +1 -1
- package/dist/runtime/coordinate-runner-feature.d.ts +20 -0
- package/dist/tokens.d.ts +1 -0
- package/package.json +30 -35
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -4
- package/.turbo/turbo-lint$colon$fix.log +0 -4
- package/.turbo/turbo-prettify.log +0 -0
- package/.turbo/turbo-test.log +0 -12
- package/CHANGELOG.md +0 -1266
- package/dist/esm/index.js +0 -515
- package/dist/esm/index.js.map +0 -1
- package/dist/index.d.cts +0 -674
- package/tsup.config.ts +0 -14
package/README.md
CHANGED
|
@@ -1,122 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Introduction
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
# NOTICE
|
|
6
|
-
|
|
7
|
-
Autometa is under construction. It is currently unstable, poorly documented and not production ready for most cases.
|
|
8
|
-
|
|
9
|
-
Check back soon.
|
|
10
|
-
|
|
11
|
-
The following libraries may be considered relatively stable, but may contain bugs or unclear errors
|
|
12
|
-
|
|
13
|
-
- [Overloaded](libraries/overloaded/) - Function and method overloads that are as pleasant to make as they are to use
|
|
14
|
-
- [Bind Decorator](libraries/bind-decorator/) - Binds the `this` keyword on a class method. Respectfully a fork of [bind-decorator](https://www.npmjs.com/package/autobind-decorator)
|
|
15
|
-
- [Status Codes](libraries/status-codes/) - Object containing HTTP status
|
|
16
|
-
codes and status messages, visible in the editor via `as const`
|
|
17
|
-
|
|
18
|
-
# Autometa
|
|
19
|
-
|
|
20
|
-
_Autometa_ is an early-development automation framework toolkit, which provides libraries to help automate the automation process on node with libraries to
|
|
21
|
-
help bootstrap your node automation framework, for API or E2E testing.
|
|
22
|
-
|
|
23
|
-
[Full Docs](https://bendat.github.io/autometa/docs/cucumber/test_runner/intro/)
|
|
24
|
-
|
|
25
|
-
## Cucumber Runner
|
|
26
|
-
|
|
27
|
-
The Cucumber Runner lets you build and execute Cucumber style tests with alternative test runners. Currently supported are `jest`.
|
|
28
|
-
|
|
29
|
-
Initially inspired by [jest-cucumber](github.com/bencompton/jest-cucumber) provides a customizable hybrid approach between cucumbers flat global steps
|
|
30
|
-
and jest-cucumbers nested spec-like tests.
|
|
31
|
-
|
|
32
|
-
Dependency injection is supported to make initializing client classes needed to interface with your service or website simple and logic-free, with unique copies
|
|
33
|
-
provided to each executing tests.
|
|
34
|
-
|
|
35
|
-
```ts title='Cucumber like'
|
|
36
|
-
import { Feature, Given, When, Then, Before } from "@autometa/runner";
|
|
37
|
-
import { App } from "./my-app";
|
|
38
|
-
import * as seedData from "./seed-data";
|
|
39
|
-
|
|
40
|
-
Before("Seed the database", async ({ dbClient }: App) => {
|
|
41
|
-
await dbClient.seed(seedData);
|
|
42
|
-
});
|
|
43
|
-
Given("a user who wants to log in", () => {});
|
|
44
|
-
When("a user submits their credentials", () => {});
|
|
45
|
-
Then("a user sees their", () => {});
|
|
46
|
-
|
|
47
|
-
// tests assembled automatically
|
|
48
|
-
Feature("./my-feature.feature");
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Steps can also be nested or groups to override higher level
|
|
52
|
-
steps.
|
|
53
|
-
|
|
54
|
-
```ts title='Jest-Cucumber like'
|
|
55
|
-
import {
|
|
56
|
-
Feature,
|
|
57
|
-
Given,
|
|
58
|
-
When,
|
|
59
|
-
Then,
|
|
60
|
-
Before,
|
|
61
|
-
ScenarioOutline,
|
|
62
|
-
Scenario,
|
|
63
|
-
Rule,
|
|
64
|
-
} from "@autometa/runner";
|
|
65
|
-
import { App } from "./my-app";
|
|
66
|
-
import * as seedData from "./seed-data";
|
|
67
|
-
|
|
68
|
-
Before("Seed the database", async ({ dbClient }: App) => {
|
|
69
|
-
await dbClient.seed(seedData);
|
|
70
|
-
});
|
|
71
|
-
Given("a user who wants to log in", () => {});
|
|
72
|
-
When("a user submits their credentials", () => {});
|
|
73
|
-
|
|
74
|
-
Feature(() => {
|
|
75
|
-
Scenario("a user logs in successfully", () => {
|
|
76
|
-
Then("a user sees their profile", () => {});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
Scenario("a user cannot log in without a password", () => {
|
|
80
|
-
Then(
|
|
81
|
-
"a user is informed they cannot log in",
|
|
82
|
-
(expectedError: string) => {}
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
Rule("a rule", () => {
|
|
86
|
-
ScenarioOutline("some outline", () => {
|
|
87
|
-
// define steps unique to `some outline`
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}, "./my-feature.feature");
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Dto Builder
|
|
94
|
-
|
|
95
|
-
Implementation of the Builder pattern that allows automatically generating
|
|
96
|
-
builder classes from a DTO class prototype, with type-safe builder methods in
|
|
97
|
-
place of DTO properties.
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
import { dto, Builder } from '@autometa/dto-builder'
|
|
101
|
-
export class UserDto {
|
|
102
|
-
id: number
|
|
103
|
-
username: string,
|
|
104
|
-
// default values, factories, dtos
|
|
105
|
-
@DTO.dto(AddressDto)
|
|
106
|
-
address: AddressDto
|
|
107
|
-
@DTO.date()
|
|
108
|
-
createdAt: Date
|
|
109
|
-
}
|
|
110
|
-
// or
|
|
111
|
-
// avoid duplicating interface properties
|
|
112
|
-
export class UserDto extends DTO<IUser> {}
|
|
113
|
-
|
|
114
|
-
const UserDtoBuilder = Builder(UserDto);
|
|
115
|
-
|
|
116
|
-
const user = new UserDtoBuilder().id(1).name('bob').build()
|
|
117
|
-
|
|
118
|
-
// compilation error, 'first argument of "id" must be a number"
|
|
119
|
-
new UserDtoBuilder().id('1').name('bob').build()
|
|
120
|
-
// force it to pass a string
|
|
121
|
-
new UserDtoBuilder().id('1' as unknown as number).name('bob').build()
|
|
122
|
-
```
|
|
3
|
+
There's nothing here yet
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { StepExpression } from "@autometa/scopes";
|
|
2
|
+
import { Scope, type IContainer, type Identifier } from "@autometa/injection";
|
|
3
|
+
import type { RunnerEnvironment } from "../dsl/create-runner";
|
|
4
|
+
type StepDecorator = (expression: StepExpression) => MethodDecorator;
|
|
5
|
+
/**
|
|
6
|
+
* Surface returned by `runner.bindingsTS()` for TypeScript experimental decorators.
|
|
7
|
+
* Provides class-based step definitions with dependency injection support.
|
|
8
|
+
*/
|
|
9
|
+
export interface RunnerBindingsSurface<_World> {
|
|
10
|
+
/**
|
|
11
|
+
* Class decorator that marks a class as containing step definitions.
|
|
12
|
+
* The class will be registered with the DI container and its step methods
|
|
13
|
+
* will be automatically registered with the runner.
|
|
14
|
+
*/
|
|
15
|
+
readonly Binding: () => ClassDecorator;
|
|
16
|
+
/**
|
|
17
|
+
* Step method decorators - use on methods within a @Binding class.
|
|
18
|
+
*/
|
|
19
|
+
readonly Given: StepDecorator;
|
|
20
|
+
readonly When: StepDecorator;
|
|
21
|
+
readonly Then: StepDecorator;
|
|
22
|
+
readonly And: StepDecorator;
|
|
23
|
+
readonly But: StepDecorator;
|
|
24
|
+
/**
|
|
25
|
+
* DI decorators for registering and injecting dependencies.
|
|
26
|
+
*/
|
|
27
|
+
readonly Injectable: (options?: {
|
|
28
|
+
scope?: Scope;
|
|
29
|
+
}) => ClassDecorator;
|
|
30
|
+
readonly Inject: (token: Identifier) => ParameterDecorator & PropertyDecorator;
|
|
31
|
+
readonly LazyInject: (token: Identifier) => PropertyDecorator;
|
|
32
|
+
/**
|
|
33
|
+
* The global container used for registrations.
|
|
34
|
+
* Can be used for advanced scenarios like manual registration.
|
|
35
|
+
*/
|
|
36
|
+
readonly container: IContainer;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates the bindings surface for TypeScript experimental decorators.
|
|
40
|
+
* This provides class-based step definitions with full DI support.
|
|
41
|
+
*
|
|
42
|
+
* Note: This function requires reflect-metadata to be imported by the user.
|
|
43
|
+
* The import is done lazily to avoid breaking projects that don't use bindings.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createBindingsTS<World>(stepsEnvironment: RunnerEnvironment<World, Record<string, unknown>>): RunnerBindingsSurface<World>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createBindingsTS, type RunnerBindingsSurface, } from "./create-bindings-ts";
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { type AssertionPlugin, type EnsureFacade, type EnsureInvoke, type EnsurePluginFacets, type EnsureOptions, type EnsureChain } from "@autometa/assertions";
|
|
2
|
+
import type { CoordinateFeatureResult } from "@autometa/coordinator";
|
|
3
|
+
import { Scope, type Constructor, type IContainer, type Identifier, type RegistrationOptions, type Token } from "@autometa/injection";
|
|
4
|
+
import type { CucumberExpressionTypeMap, DefaultCucumberExpressionTypes, WorldFactory } from "@autometa/scopes";
|
|
5
|
+
import type { ParameterTypeDefinitions } from "@autometa/cucumber-expressions";
|
|
6
|
+
import type { RunnerContextOptions } from "../core/runner-context";
|
|
7
|
+
import { type RunnerEnvironment } from "../dsl/create-runner";
|
|
8
|
+
import { type GlobalRunner } from "../dsl/create-global-runner";
|
|
9
|
+
import { type DecoratorRunnerEnvironment } from "../dsl/create-decorator-runner";
|
|
10
|
+
import { type RunnerDecorators } from "../decorators/create-runner-decorators";
|
|
11
|
+
import { type RunnerBindingsSurface } from "../bindings/create-bindings-ts";
|
|
12
|
+
import { type CoordinateRunnerFeatureOptions } from "../runtime/coordinate-runner-feature";
|
|
13
|
+
export type DefaultEnsureFacets = Record<string, never>;
|
|
14
|
+
export type RunnerEnsureFactory<World, Facets extends Record<string, unknown>> = Facets & {
|
|
15
|
+
(world: World): EnsureFacade<World, Facets>;
|
|
16
|
+
<T>(value: T, options?: EnsureOptions): EnsureChain<T>;
|
|
17
|
+
readonly world: World;
|
|
18
|
+
readonly not: Facets;
|
|
19
|
+
};
|
|
20
|
+
export type AssertionSetup<World, Facets extends Record<string, unknown>> = (ensure: EnsureInvoke) => RunnerEnsureFactory<World, Facets>;
|
|
21
|
+
export declare const WORLD_INHERIT_KEYS: unique symbol;
|
|
22
|
+
export type StepsEnvironmentMeta = {
|
|
23
|
+
readonly kind: "root";
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: "group";
|
|
26
|
+
readonly group: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const STEPS_ENVIRONMENT_META: symbol;
|
|
29
|
+
type AppPropertyInjection = Identifier | {
|
|
30
|
+
readonly token: Identifier;
|
|
31
|
+
readonly lazy?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export interface AppClassRegistrationOptions {
|
|
34
|
+
readonly scope?: Scope;
|
|
35
|
+
readonly tags?: readonly string[];
|
|
36
|
+
readonly deps?: readonly Identifier[];
|
|
37
|
+
readonly inject?: Record<PropertyKey, AppPropertyInjection>;
|
|
38
|
+
}
|
|
39
|
+
export interface AppRegistrationOptions<App, World> extends AppClassRegistrationOptions {
|
|
40
|
+
readonly configure?: (instance: App, context: AppFactoryContext<World>) => void | Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface AppCompositionOptions<App, World> extends AppRegistrationOptions<App, World> {
|
|
43
|
+
readonly setup?: (context: AppFactoryContext<World>) => void | Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export interface AppFactoryContext<World> {
|
|
46
|
+
readonly container: IContainer;
|
|
47
|
+
readonly world: World;
|
|
48
|
+
registerClass<T>(target: Constructor<T>, options?: AppClassRegistrationOptions): AppFactoryContext<World>;
|
|
49
|
+
registerValue<T>(identifier: Identifier<T>, value: T, options?: RegistrationOptions): AppFactoryContext<World>;
|
|
50
|
+
registerFactory<T>(identifier: Identifier<T>, factory: (container: IContainer) => T, options?: RegistrationOptions): AppFactoryContext<World>;
|
|
51
|
+
registerToken<T>(token: Token<T>, target: Constructor<T> | ((container: IContainer) => T), options?: RegistrationOptions): AppFactoryContext<World>;
|
|
52
|
+
registerApp<T>(target: Constructor<T>, options?: AppRegistrationOptions<T, World>): Promise<T>;
|
|
53
|
+
getRegisteredApp(): unknown;
|
|
54
|
+
resolve<T>(identifier: Identifier<T>): T;
|
|
55
|
+
}
|
|
56
|
+
export declare const App: {
|
|
57
|
+
compositionRoot<Ctor extends Constructor<unknown>, World = unknown>(ctor: Ctor, options?: AppCompositionOptions<InstanceType<Ctor>, World> | undefined): AppFactoryInput<World, InstanceType<Ctor>>;
|
|
58
|
+
};
|
|
59
|
+
type AppFactoryInput<World, App> = App | (() => App | Promise<App>) | ((context: AppFactoryContext<World>) => App | Promise<App>);
|
|
60
|
+
export type WorldWithApp<World, App> = World extends {
|
|
61
|
+
app: infer _Existing;
|
|
62
|
+
} ? Omit<World, "app"> & {
|
|
63
|
+
readonly app: App;
|
|
64
|
+
} : World & {
|
|
65
|
+
readonly app: App;
|
|
66
|
+
};
|
|
67
|
+
export interface RunnerStepsSurface<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes, Facets extends Record<string, unknown> = DefaultEnsureFacets> extends RunnerEnvironment<World, ExpressionTypes> {
|
|
68
|
+
readonly globals: GlobalRunner<World, ExpressionTypes>;
|
|
69
|
+
coordinateFeature(options: RunnerCoordinateFeatureOptions<World>): CoordinateFeatureResult<World>;
|
|
70
|
+
readonly ensure: RunnerEnsureFactory<World, Facets>;
|
|
71
|
+
}
|
|
72
|
+
export interface RunnerDecoratorsSurface<World> extends RunnerDecorators<World> {
|
|
73
|
+
readonly environment: DecoratorRunnerEnvironment<World>;
|
|
74
|
+
}
|
|
75
|
+
export interface RunnerBuilder<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes, Facets extends Record<string, unknown> = DefaultEnsureFacets> {
|
|
76
|
+
/**
|
|
77
|
+
* Creates an isolated copy of this builder.
|
|
78
|
+
*
|
|
79
|
+
* This is the foundation for per-group/per-domain runner environments.
|
|
80
|
+
*
|
|
81
|
+
* Notes:
|
|
82
|
+
* - Caches are cleared on the fork.
|
|
83
|
+
* - Factories (world/app) are copied by reference.
|
|
84
|
+
*/
|
|
85
|
+
fork(): DerivableRunnerBuilder<World, ExpressionTypes, Facets>;
|
|
86
|
+
/**
|
|
87
|
+
* Enables group-based derivation on this builder.
|
|
88
|
+
*
|
|
89
|
+
* This is primarily a typing affordance; it does not change runtime behavior.
|
|
90
|
+
*/
|
|
91
|
+
derivable(): DerivableRunnerBuilder<World, ExpressionTypes, Facets>;
|
|
92
|
+
/**
|
|
93
|
+
* Returns (and caches) a derived builder for a given group/domain key.
|
|
94
|
+
*
|
|
95
|
+
* The derived builder is a fork taken at first access.
|
|
96
|
+
*/
|
|
97
|
+
group(key: string): DerivableRunnerBuilder<World, ExpressionTypes, Facets>;
|
|
98
|
+
/**
|
|
99
|
+
* Composes a world factory on top of the current world.
|
|
100
|
+
*
|
|
101
|
+
* The resulting world is a shallow merge of (baseWorld, extensionWorld), with
|
|
102
|
+
* extension keys taking precedence.
|
|
103
|
+
*/
|
|
104
|
+
extendWorld<ExtensionWorld = Record<string, unknown>>(value?: Partial<ExtensionWorld> | WorldFactory<ExtensionWorld>): RunnerBuilder<World & ExtensionWorld, ExpressionTypes, DefaultEnsureFacets>;
|
|
105
|
+
/**
|
|
106
|
+
* Extends application configuration while preserving the existing app factory.
|
|
107
|
+
*
|
|
108
|
+
* App factories are executed in sequence; later factories may override the
|
|
109
|
+
* application instance by returning/registering a different app.
|
|
110
|
+
*/
|
|
111
|
+
extendApp<App>(app: AppFactoryInput<World, App>): RunnerBuilder<WorldWithApp<World, App>, ExpressionTypes, DefaultEnsureFacets>;
|
|
112
|
+
configure(update: Partial<RunnerContextOptions<World>> | ((current: RunnerContextOptions<World>) => RunnerContextOptions<World>)): RunnerBuilder<World, ExpressionTypes, Facets>;
|
|
113
|
+
expressionMap<NextExpressionTypes extends CucumberExpressionTypeMap>(): RunnerBuilder<World, NextExpressionTypes, Facets>;
|
|
114
|
+
withWorld<NextWorld = World>(value?: Partial<NextWorld> | WorldFactory<NextWorld>): RunnerBuilder<NextWorld, ExpressionTypes, DefaultEnsureFacets>;
|
|
115
|
+
app<App>(app: AppFactoryInput<World, App>): RunnerBuilder<WorldWithApp<World, App>, ExpressionTypes, DefaultEnsureFacets>;
|
|
116
|
+
assertions<NextFacets extends Record<string, unknown>>(setup: AssertionSetup<World, NextFacets>): RunnerBuilder<World, ExpressionTypes, NextFacets>;
|
|
117
|
+
assertionPlugins<NextPlugins extends Record<string, AssertionPlugin<World, unknown>>>(plugins: NextPlugins): RunnerBuilder<World, ExpressionTypes, EnsurePluginFacets<World, NextPlugins>>;
|
|
118
|
+
parameterTypes(definitions: ParameterTypeDefinitions<World>): RunnerBuilder<World, ExpressionTypes, Facets>;
|
|
119
|
+
steps(): RunnerStepsSurface<World, ExpressionTypes, Facets>;
|
|
120
|
+
decorators(): RunnerDecoratorsSurface<World>;
|
|
121
|
+
/**
|
|
122
|
+
* Returns binding decorators for TypeScript experimental decorators.
|
|
123
|
+
* Use this for class-based step definitions with dependency injection.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const { Binding, Given, When, Then, Injectable, Inject } = runner.bindingsTS();
|
|
128
|
+
*
|
|
129
|
+
* @Injectable()
|
|
130
|
+
* class MyService { ... }
|
|
131
|
+
*
|
|
132
|
+
* @Binding()
|
|
133
|
+
* class MySteps {
|
|
134
|
+
* constructor(
|
|
135
|
+
* @Inject(WORLD_TOKEN) private world: MyWorld,
|
|
136
|
+
* @Inject(MyService) private service: MyService
|
|
137
|
+
* ) {}
|
|
138
|
+
*
|
|
139
|
+
* @Given("some step")
|
|
140
|
+
* myStep() { ... }
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
bindingsTS(): RunnerBindingsSurface<World>;
|
|
145
|
+
}
|
|
146
|
+
export type DerivableRunnerBuilder<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes, Facets extends Record<string, unknown> = DefaultEnsureFacets> = RunnerBuilder<World, ExpressionTypes, Facets>;
|
|
147
|
+
export type RunnerCoordinateFeatureOptions<World> = Omit<CoordinateRunnerFeatureOptions<World>, "environment">;
|
|
148
|
+
export declare function createRunnerBuilder<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes>(initial?: Partial<RunnerContextOptions<World>>): RunnerBuilder<World, ExpressionTypes, DefaultEnsureFacets>;
|
|
149
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ParameterType } from "@cucumber/cucumber-expressions";
|
|
2
|
+
import { ParameterTypeRegistry } from "@cucumber/cucumber-expressions";
|
|
3
|
+
import type { ParameterRegistryLike } from "@autometa/scopes";
|
|
4
|
+
export interface ParameterRegistryAdapterOptions {
|
|
5
|
+
readonly registry?: ParameterTypeRegistry;
|
|
6
|
+
}
|
|
7
|
+
export declare class ParameterRegistryAdapter implements ParameterRegistryLike {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(options?: ParameterRegistryAdapterOptions);
|
|
10
|
+
get registry(): ParameterTypeRegistry;
|
|
11
|
+
get parameterTypes(): Iterable<ParameterType<unknown>>;
|
|
12
|
+
lookupByTypeName(name: string): ParameterType<unknown> | undefined;
|
|
13
|
+
lookupByRegexp(parameterTypeRegexp: string, expressionRegexp: RegExp, text: string): ParameterType<unknown> | undefined;
|
|
14
|
+
defineParameterType(definition: unknown): ParameterType<unknown>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createParameterRegistryAdapter(options?: ParameterRegistryAdapterOptions): ParameterRegistryAdapter;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type CreateParameterTypesOptions, type ParameterTypeDefinition, type ParameterTypeDefinitions } from "@autometa/cucumber-expressions";
|
|
2
|
+
import type { CreateScopesOptions, CucumberExpressionTypeMap, ScopePlan, ScopesDsl, WithDefaultCucumberExpressionTypes, DefaultCucumberExpressionTypes } from "@autometa/scopes";
|
|
3
|
+
import type { ParameterType, ParameterTypeRegistry } from "@cucumber/cucumber-expressions";
|
|
4
|
+
import { ParameterRegistryAdapter } from "./parameter-registry";
|
|
5
|
+
export type RunnerScopeOptions<World> = Omit<CreateScopesOptions<World>, "parameterRegistry">;
|
|
6
|
+
export interface RunnerContextOptions<World> extends RunnerScopeOptions<World> {
|
|
7
|
+
readonly parameterRegistry?: ParameterTypeRegistry;
|
|
8
|
+
readonly parameterTypes?: ParameterTypeDefinitions<World>;
|
|
9
|
+
readonly parameterTypesOptions?: CreateParameterTypesOptions;
|
|
10
|
+
readonly registerDefaultParameterTypes?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class RunnerContext<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes> {
|
|
13
|
+
private readonly scopesInternal;
|
|
14
|
+
private readonly registryAdapter;
|
|
15
|
+
private readonly defineParameterTypeFn;
|
|
16
|
+
private readonly registerDefaultParameterTypesFn;
|
|
17
|
+
constructor(options?: RunnerContextOptions<World>);
|
|
18
|
+
get scopes(): ScopesDsl<World, WithDefaultCucumberExpressionTypes<ExpressionTypes>>;
|
|
19
|
+
get parameterRegistry(): ParameterTypeRegistry;
|
|
20
|
+
get parameterRegistryAdapter(): ParameterRegistryAdapter;
|
|
21
|
+
get plan(): ScopePlan<World>;
|
|
22
|
+
defineParameterType(definition: ParameterTypeDefinition<World>): ParameterType<unknown>;
|
|
23
|
+
defineParameterTypes(...definitions: ParameterTypeDefinition<World>[]): ParameterTypeRegistry;
|
|
24
|
+
registerDefaultParameterTypes(): ParameterTypeRegistry;
|
|
25
|
+
lookupParameterType(name: string): ParameterType<unknown> | undefined;
|
|
26
|
+
static extractScopeOptions<World>(options: RunnerContextOptions<World>): RunnerScopeOptions<World>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CucumberExpressionTypeMap, DefaultCucumberExpressionTypes } from "@autometa/scopes";
|
|
2
|
+
import { type RunnerBuilder, type RunnerStepsSurface } from "./builder/create-runner-builder";
|
|
3
|
+
import type { RunnerContextOptions } from "./core/runner-context";
|
|
4
|
+
export declare class CucumberRunner {
|
|
5
|
+
static builder<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes>(initial?: Partial<RunnerContextOptions<World>>): RunnerBuilder<World, ExpressionTypes>;
|
|
6
|
+
static setSteps<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes>(steps: RunnerStepsSurface<World, ExpressionTypes>): void;
|
|
7
|
+
static steps<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes>(): RunnerStepsSurface<World, ExpressionTypes>;
|
|
8
|
+
static clearSteps(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RunnerStepsSurface } from "./builder/create-runner-builder";
|
|
2
|
+
import type { CucumberExpressionTypeMap, DefaultCucumberExpressionTypes } from "@autometa/scopes";
|
|
3
|
+
export declare function setCurrentRunnerSteps<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes>(steps: RunnerStepsSurface<World, ExpressionTypes>): void;
|
|
4
|
+
export declare function getCurrentRunnerSteps<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes>(): RunnerStepsSurface<World, ExpressionTypes>;
|
|
5
|
+
export declare function clearCurrentRunnerSteps(): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { DecoratorFeatureDescriptor, DecoratorRuleDescriptor, DecoratorScenarioDescriptor, HookOptions, StepExpression, StepOptions, StepTagInput } from "@autometa/scopes";
|
|
2
|
+
import type { DecoratorRegistrationApi } from "../dsl/decorator-shared";
|
|
3
|
+
interface FeatureDecoratorOptions extends Partial<Omit<DecoratorFeatureDescriptor, "name">> {
|
|
4
|
+
readonly name?: string;
|
|
5
|
+
}
|
|
6
|
+
interface RuleDecoratorOptions extends Partial<Omit<DecoratorRuleDescriptor, "name">> {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
}
|
|
9
|
+
interface ScenarioDecoratorOptions extends Partial<Omit<DecoratorScenarioDescriptor, "name">> {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly steps?: readonly PropertyKey[];
|
|
12
|
+
readonly rule?: PropertyKey;
|
|
13
|
+
}
|
|
14
|
+
interface StepDecoratorOptions extends StepOptions {
|
|
15
|
+
readonly scenario: PropertyKey | readonly PropertyKey[];
|
|
16
|
+
}
|
|
17
|
+
interface ScenarioHookDecoratorOptions extends HookOptions {
|
|
18
|
+
readonly scenario: PropertyKey | readonly PropertyKey[];
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
}
|
|
21
|
+
interface FeatureHookDecoratorOptions extends HookOptions {
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
}
|
|
24
|
+
interface RuleHookDecoratorOptions extends HookOptions {
|
|
25
|
+
readonly rule: PropertyKey | readonly PropertyKey[];
|
|
26
|
+
readonly description?: string;
|
|
27
|
+
}
|
|
28
|
+
type StepDecoratorFactory<World> = {
|
|
29
|
+
(expression: StepExpression, options: StepDecoratorOptions): MethodDecorator;
|
|
30
|
+
skip: StepDecoratorFactory<World>;
|
|
31
|
+
only: StepDecoratorFactory<World>;
|
|
32
|
+
failing: StepDecoratorFactory<World>;
|
|
33
|
+
concurrent: StepDecoratorFactory<World>;
|
|
34
|
+
tags: (...tags: readonly StepTagInput[]) => StepDecoratorFactory<World>;
|
|
35
|
+
};
|
|
36
|
+
export interface RunnerDecorators<_World> {
|
|
37
|
+
Feature(options?: FeatureDecoratorOptions): ClassDecorator;
|
|
38
|
+
Rule(options: RuleDecoratorOptions): MethodDecorator;
|
|
39
|
+
Scenario(options: ScenarioDecoratorOptions): MethodDecorator;
|
|
40
|
+
Given: StepDecoratorFactory<_World>;
|
|
41
|
+
When: StepDecoratorFactory<_World>;
|
|
42
|
+
Then: StepDecoratorFactory<_World>;
|
|
43
|
+
And: StepDecoratorFactory<_World>;
|
|
44
|
+
But: StepDecoratorFactory<_World>;
|
|
45
|
+
BeforeFeature(options?: FeatureHookDecoratorOptions): MethodDecorator;
|
|
46
|
+
AfterFeature(options?: FeatureHookDecoratorOptions): MethodDecorator;
|
|
47
|
+
BeforeRule(options: RuleHookDecoratorOptions): MethodDecorator;
|
|
48
|
+
AfterRule(options: RuleHookDecoratorOptions): MethodDecorator;
|
|
49
|
+
BeforeScenario(options: ScenarioHookDecoratorOptions): MethodDecorator;
|
|
50
|
+
AfterScenario(options: ScenarioHookDecoratorOptions): MethodDecorator;
|
|
51
|
+
BeforeScenarioOutline(options: ScenarioHookDecoratorOptions): MethodDecorator;
|
|
52
|
+
AfterScenarioOutline(options: ScenarioHookDecoratorOptions): MethodDecorator;
|
|
53
|
+
}
|
|
54
|
+
export declare function createRunnerDecorators<World>(environment: DecoratorRegistrationApi<World>): RunnerDecorators<World>;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type DecoratorFeatureDescriptor, type DecoratorRuleDescriptor, type DecoratorScenarioDescriptor, type HookHandler, type HookOptions, type HookType, type ScopePlan, type StepExpression, type StepHandler, type StepKeyword, type StepOptions } from "@autometa/scopes";
|
|
2
|
+
import { RunnerContext, type RunnerContextOptions } from "../core/runner-context";
|
|
3
|
+
interface ScenarioContext {
|
|
4
|
+
readonly feature: unknown;
|
|
5
|
+
readonly rule?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface DecoratorRegistrationApi<World> {
|
|
8
|
+
feature(token: unknown, descriptor: DecoratorFeatureDescriptor): void;
|
|
9
|
+
rule(featureToken: unknown, token: unknown, descriptor: DecoratorRuleDescriptor): void;
|
|
10
|
+
scenario(token: unknown, descriptor: DecoratorScenarioDescriptor, context: ScenarioContext): void;
|
|
11
|
+
step(scenarioToken: unknown, keyword: StepKeyword, expression: StepExpression, handler: StepHandler<World>, options?: StepOptions): void;
|
|
12
|
+
hook(scopeToken: unknown, type: HookType, handler: HookHandler<World>, description?: string, options?: HookOptions): void;
|
|
13
|
+
}
|
|
14
|
+
export interface DecoratorRunnerEnvironment<World> extends DecoratorRegistrationApi<World> {
|
|
15
|
+
readonly context: RunnerContext<World>;
|
|
16
|
+
buildPlan(): ScopePlan<World>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createDecoratorRunner<World>(options?: RunnerContextOptions<World>): DecoratorRunnerEnvironment<World>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type RunnerEnvironment } from "./create-runner";
|
|
2
|
+
import type { RunnerContextOptions } from "../core/runner-context";
|
|
3
|
+
import type { CucumberExpressionTypeMap, DefaultCucumberExpressionTypes } from "@autometa/scopes";
|
|
4
|
+
export interface GlobalRunner<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes> extends RunnerEnvironment<World, ExpressionTypes> {
|
|
5
|
+
reset(options?: RunnerContextOptions<World>): RunnerEnvironment<World, ExpressionTypes>;
|
|
6
|
+
useEnvironment(environment: RunnerEnvironment<World, ExpressionTypes>): RunnerEnvironment<World, ExpressionTypes>;
|
|
7
|
+
getEnvironment(): RunnerEnvironment<World, ExpressionTypes>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createGlobalRunner<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes>(initialOptions?: RunnerContextOptions<World>): GlobalRunner<World, ExpressionTypes>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { HookHandler, HookRegistration, ScopePlan, ScopesDsl, StepArgumentsForExpression, StepDefinition, StepExpression, StepOptions, StepTagInput, HookOptions, CucumberExpressionTypeMap, DefaultCucumberExpressionTypes, WithDefaultCucumberExpressionTypes } from "@autometa/scopes";
|
|
2
|
+
import type { ParameterTypeDefinition, ParameterTypeDefinitions } from "@autometa/cucumber-expressions";
|
|
3
|
+
import type { ParameterType, ParameterTypeRegistry } from "@cucumber/cucumber-expressions";
|
|
4
|
+
import { type StepRuntimeHelpers } from "@autometa/executor";
|
|
5
|
+
import { RunnerContext, type RunnerContextOptions } from "../core/runner-context";
|
|
6
|
+
type StepHandlerWithOptionalThis<World, TArgs extends unknown[]> = ((this: World, ...args: TArgs) => unknown | Promise<unknown>) | ((...args: TArgs) => unknown | Promise<unknown>);
|
|
7
|
+
export type RuntimeAwareStepHandler<World, TArgs extends unknown[] = unknown[]> = StepHandlerWithOptionalThis<World, [
|
|
8
|
+
...TArgs,
|
|
9
|
+
StepRuntimeHelpers,
|
|
10
|
+
World
|
|
11
|
+
]>;
|
|
12
|
+
export type RunnerStepHandler<World, TArgs extends unknown[] = unknown[]> = StepHandlerWithOptionalThis<World, [...TArgs, World]> | RuntimeAwareStepHandler<World, TArgs>;
|
|
13
|
+
type StepExpressionArguments<Expression extends StepExpression, ExpressionTypes extends CucumberExpressionTypeMap> = StepArgumentsForExpression<Expression, WithDefaultCucumberExpressionTypes<ExpressionTypes>>;
|
|
14
|
+
export interface RunnerStepDsl<World, ExpressionTypes extends CucumberExpressionTypeMap> {
|
|
15
|
+
<Expression extends StepExpression>(expression: Expression, handler: StepHandlerWithOptionalThis<World, [
|
|
16
|
+
...StepExpressionArguments<Expression, ExpressionTypes>,
|
|
17
|
+
World
|
|
18
|
+
]>, options?: StepOptions): StepDefinition<World>;
|
|
19
|
+
<Expression extends StepExpression>(expression: Expression, handler: StepHandlerWithOptionalThis<World, [
|
|
20
|
+
...StepExpressionArguments<Expression, ExpressionTypes>,
|
|
21
|
+
StepRuntimeHelpers,
|
|
22
|
+
World
|
|
23
|
+
]>, options?: StepOptions): StepDefinition<World>;
|
|
24
|
+
skip: RunnerStepDsl<World, ExpressionTypes>;
|
|
25
|
+
only: RunnerStepDsl<World, ExpressionTypes>;
|
|
26
|
+
failing: RunnerStepDsl<World, ExpressionTypes>;
|
|
27
|
+
concurrent: RunnerStepDsl<World, ExpressionTypes>;
|
|
28
|
+
tags: (...tags: readonly StepTagInput[]) => RunnerStepDsl<World, ExpressionTypes>;
|
|
29
|
+
}
|
|
30
|
+
export interface RunnerHookDsl<World> {
|
|
31
|
+
(handler: HookHandler<World>, options?: HookOptions): HookRegistration<World>;
|
|
32
|
+
(description: string, handler: HookHandler<World>, options?: HookOptions): HookRegistration<World>;
|
|
33
|
+
skip: RunnerHookDsl<World>;
|
|
34
|
+
only: RunnerHookDsl<World>;
|
|
35
|
+
failing: RunnerHookDsl<World>;
|
|
36
|
+
concurrent: RunnerHookDsl<World>;
|
|
37
|
+
}
|
|
38
|
+
type BaseScopesDsl<World, ExpressionTypes extends CucumberExpressionTypeMap> = Omit<ScopesDsl<World, ExpressionTypes>, "given" | "when" | "then" | "and" | "but" | "Given" | "When" | "Then" | "And" | "But" | "beforeFeature" | "afterFeature" | "beforeRule" | "afterRule" | "beforeScenario" | "afterScenario" | "beforeScenarioOutline" | "afterScenarioOutline" | "beforeStep" | "afterStep">;
|
|
39
|
+
export interface RunnerDsl<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes> extends BaseScopesDsl<World, WithDefaultCucumberExpressionTypes<ExpressionTypes>> {
|
|
40
|
+
readonly given: RunnerStepDsl<World, ExpressionTypes>;
|
|
41
|
+
readonly when: RunnerStepDsl<World, ExpressionTypes>;
|
|
42
|
+
readonly then: RunnerStepDsl<World, ExpressionTypes>;
|
|
43
|
+
readonly and: RunnerStepDsl<World, ExpressionTypes>;
|
|
44
|
+
readonly but: RunnerStepDsl<World, ExpressionTypes>;
|
|
45
|
+
readonly Given: RunnerStepDsl<World, ExpressionTypes>;
|
|
46
|
+
readonly When: RunnerStepDsl<World, ExpressionTypes>;
|
|
47
|
+
readonly Then: RunnerStepDsl<World, ExpressionTypes>;
|
|
48
|
+
readonly And: RunnerStepDsl<World, ExpressionTypes>;
|
|
49
|
+
readonly But: RunnerStepDsl<World, ExpressionTypes>;
|
|
50
|
+
readonly beforeFeature: RunnerHookDsl<World>;
|
|
51
|
+
readonly afterFeature: RunnerHookDsl<World>;
|
|
52
|
+
readonly beforeRule: RunnerHookDsl<World>;
|
|
53
|
+
readonly afterRule: RunnerHookDsl<World>;
|
|
54
|
+
readonly beforeScenario: RunnerHookDsl<World>;
|
|
55
|
+
readonly afterScenario: RunnerHookDsl<World>;
|
|
56
|
+
readonly beforeScenarioOutline: RunnerHookDsl<World>;
|
|
57
|
+
readonly afterScenarioOutline: RunnerHookDsl<World>;
|
|
58
|
+
readonly beforeStep: RunnerHookDsl<World>;
|
|
59
|
+
readonly afterStep: RunnerHookDsl<World>;
|
|
60
|
+
readonly BeforeFeature: RunnerHookDsl<World>;
|
|
61
|
+
readonly AfterFeature: RunnerHookDsl<World>;
|
|
62
|
+
readonly BeforeRule: RunnerHookDsl<World>;
|
|
63
|
+
readonly AfterRule: RunnerHookDsl<World>;
|
|
64
|
+
readonly BeforeScenario: RunnerHookDsl<World>;
|
|
65
|
+
readonly AfterScenario: RunnerHookDsl<World>;
|
|
66
|
+
readonly BeforeScenarioOutline: RunnerHookDsl<World>;
|
|
67
|
+
readonly AfterScenarioOutline: RunnerHookDsl<World>;
|
|
68
|
+
readonly BeforeStep: RunnerHookDsl<World>;
|
|
69
|
+
readonly AfterStep: RunnerHookDsl<World>;
|
|
70
|
+
}
|
|
71
|
+
export interface RunnerEnvironment<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes> extends RunnerDsl<World, ExpressionTypes> {
|
|
72
|
+
readonly context: RunnerContext<World, ExpressionTypes>;
|
|
73
|
+
readonly parameterRegistry: ParameterTypeRegistry;
|
|
74
|
+
readonly getPlan: () => ScopePlan<World>;
|
|
75
|
+
readonly defineParameterType: (definition: ParameterTypeDefinition<World>) => ParameterType<unknown>;
|
|
76
|
+
readonly defineParameterTypes: (...definitions: ParameterTypeDefinition<World>[]) => ParameterTypeRegistry;
|
|
77
|
+
readonly defineParameterTypesFromList: (definitions: ParameterTypeDefinitions<World>) => ParameterTypeRegistry;
|
|
78
|
+
readonly registerDefaultParameterTypes: () => ParameterTypeRegistry;
|
|
79
|
+
readonly lookupParameterType: (name: string) => ParameterType<unknown> | undefined;
|
|
80
|
+
}
|
|
81
|
+
export declare function createRunner<World, ExpressionTypes extends CucumberExpressionTypeMap = DefaultCucumberExpressionTypes>(options?: RunnerContextOptions<World>): RunnerEnvironment<World, ExpressionTypes>;
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DecoratorFeatureDescriptor, DecoratorRuleDescriptor, DecoratorScenarioDescriptor, HookHandler, HookOptions, HookType, StepExpression, StepHandler, StepKeyword, StepOptions } from "@autometa/scopes";
|
|
2
|
+
export interface ScenarioContext {
|
|
3
|
+
readonly feature: unknown;
|
|
4
|
+
readonly rule?: unknown;
|
|
5
|
+
}
|
|
6
|
+
export interface DecoratorRegistrationApi<World> {
|
|
7
|
+
feature(token: unknown, descriptor: DecoratorFeatureDescriptor): void;
|
|
8
|
+
rule(featureToken: unknown, token: unknown, descriptor: DecoratorRuleDescriptor): void;
|
|
9
|
+
scenario(token: unknown, descriptor: DecoratorScenarioDescriptor, context: ScenarioContext): void;
|
|
10
|
+
step(scenarioToken: unknown, keyword: StepKeyword, expression: StepExpression, handler: StepHandler<World>, options?: StepOptions): void;
|
|
11
|
+
hook(scopeToken: unknown, type: HookType, handler: HookHandler<World>, description?: string, options?: HookOptions): void;
|
|
12
|
+
}
|
package/dist/global.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RunnerEnvironment } from "./dsl/create-runner";
|
|
2
|
+
import type { RunnerContextOptions } from "./core/runner-context";
|
|
3
|
+
import { type GlobalRunner } from "./dsl/create-global-runner";
|
|
4
|
+
export interface GlobalWorld {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export type GlobalRunnerOptions = RunnerContextOptions<GlobalWorld>;
|
|
8
|
+
export declare function getGlobalRunner(options?: GlobalRunnerOptions): GlobalRunner<GlobalWorld, import("@autometa/scopes").DefaultCucumberExpressionTypes>;
|
|
9
|
+
export declare function configureGlobalRunner(options?: GlobalRunnerOptions): GlobalRunner<GlobalWorld, import("@autometa/scopes").DefaultCucumberExpressionTypes>;
|
|
10
|
+
export declare function resetGlobalRunner(options?: GlobalRunnerOptions): GlobalRunner<GlobalWorld, import("@autometa/scopes").DefaultCucumberExpressionTypes>;
|
|
11
|
+
export declare function disposeGlobalRunner(): void;
|
|
12
|
+
export declare function useGlobalRunnerEnvironment(environment: RunnerEnvironment<GlobalWorld>): RunnerEnvironment<GlobalWorld, import("@autometa/scopes").DefaultCucumberExpressionTypes>;
|
|
13
|
+
export declare function getGlobalRunnerEnvironment(): RunnerEnvironment<GlobalWorld, import("@autometa/scopes").DefaultCucumberExpressionTypes>;
|
|
14
|
+
export declare function getConfiguredGlobalRunner(): GlobalRunner<GlobalWorld, import("@autometa/scopes").DefaultCucumberExpressionTypes>;
|