@cucumber/cucumber 12.3.0 → 12.5.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 -0
- package/lib/api/convert_configuration.js +4 -0
- package/lib/api/convert_configuration.js.map +1 -1
- package/lib/api/index.d.ts +4 -2
- package/lib/api/index.js.map +1 -1
- package/lib/api/plugins.d.ts +1 -1
- package/lib/api/plugins.js +51 -2
- package/lib/api/plugins.js.map +1 -1
- package/lib/api/types.d.ts +25 -0
- package/lib/api/types.js.map +1 -1
- package/lib/configuration/argv_parser.d.ts +2 -0
- package/lib/configuration/argv_parser.js +2 -0
- package/lib/configuration/argv_parser.js.map +1 -1
- package/lib/configuration/default_configuration.js +2 -0
- package/lib/configuration/default_configuration.js.map +1 -1
- package/lib/configuration/from_file.js +66 -37
- package/lib/configuration/from_file.js.map +1 -1
- package/lib/configuration/types.d.ts +20 -0
- package/lib/configuration/types.js.map +1 -1
- package/lib/environment/console_logger.d.ts +1 -0
- package/lib/environment/console_logger.js +3 -0
- package/lib/environment/console_logger.js.map +1 -1
- package/lib/environment/types.d.ts +7 -0
- package/lib/environment/types.js.map +1 -1
- package/lib/filter/filter_plugin.d.ts +2 -3
- package/lib/filter/filter_plugin.js +3 -3
- package/lib/filter/filter_plugin.js.map +1 -1
- package/lib/filter/types.d.ts +4 -0
- package/lib/filter/types.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.js +0 -1
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/paths/types.d.ts +7 -0
- package/lib/paths/types.js.map +1 -1
- package/lib/plugin/plugin_manager.d.ts +9 -7
- package/lib/plugin/plugin_manager.js +67 -16
- package/lib/plugin/plugin_manager.js.map +1 -1
- package/lib/plugin/types.d.ts +120 -32
- package/lib/plugin/types.js.map +1 -1
- package/lib/publish/publish_plugin.d.ts +2 -3
- package/lib/publish/publish_plugin.js +18 -12
- package/lib/publish/publish_plugin.js.map +1 -1
- package/lib/sharding/sharding_plugin.d.ts +2 -3
- package/lib/sharding/sharding_plugin.js +2 -2
- package/lib/sharding/sharding_plugin.js.map +1 -1
- package/lib/tsconfig.node.tsbuildinfo +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +8 -8
- package/lib/plugin/events.d.ts +0 -2
- package/lib/plugin/events.js +0 -9
- package/lib/plugin/events.js.map +0 -1
|
@@ -22,6 +22,9 @@ class ConsoleLogger {
|
|
|
22
22
|
warn(message, ...optionalParams) {
|
|
23
23
|
this.console.warn(message, ...optionalParams);
|
|
24
24
|
}
|
|
25
|
+
info(message, ...optionalParams) {
|
|
26
|
+
this.console.info(message, ...optionalParams);
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
exports.ConsoleLogger = ConsoleLogger;
|
|
27
30
|
//# sourceMappingURL=console_logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console_logger.js","sourceRoot":"","sources":["../../src/environment/console_logger.ts"],"names":[],"mappings":";;;AAAA,+CAAsC;AAItC,MAAa,aAAa;IAId;IACA;IAJO,OAAO,CAAS;IAEjC,YACU,MAAgB,EAChB,YAAqB;QADrB,WAAM,GAAN,MAAM,CAAU;QAChB,iBAAY,GAAZ,YAAY,CAAS;QAE7B,IAAI,CAAC,OAAO,GAAG,IAAI,sBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,OAAa,EAAE,GAAG,cAAqB;QAC3C,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAa,EAAE,GAAG,cAAqB;QAC3C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,CAAC,OAAa,EAAE,GAAG,cAAqB;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;IAC/C,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"console_logger.js","sourceRoot":"","sources":["../../src/environment/console_logger.ts"],"names":[],"mappings":";;;AAAA,+CAAsC;AAItC,MAAa,aAAa;IAId;IACA;IAJO,OAAO,CAAS;IAEjC,YACU,MAAgB,EAChB,YAAqB;QADrB,WAAM,GAAN,MAAM,CAAU;QAChB,iBAAY,GAAZ,YAAY,CAAS;QAE7B,IAAI,CAAC,OAAO,GAAG,IAAI,sBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,OAAa,EAAE,GAAG,cAAqB;QAC3C,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAa,EAAE,GAAG,cAAqB;QAC3C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,CAAC,OAAa,EAAE,GAAG,cAAqB;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;IAC/C,CAAC;IAED,IAAI,CAAC,OAAa,EAAE,GAAG,cAAqB;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;IAC/C,CAAC;CACF;AA3BD,sCA2BC","sourcesContent":["import { Console } from 'node:console'\nimport { Writable } from 'node:stream'\nimport { ILogger } from './types'\n\nexport class ConsoleLogger implements ILogger {\n private readonly console: Console\n\n constructor(\n private stream: Writable,\n private debugEnabled: boolean\n ) {\n this.console = new Console(this.stream)\n }\n\n debug(message?: any, ...optionalParams: any[]): void {\n if (this.debugEnabled) {\n this.console.debug(message, ...optionalParams)\n }\n }\n\n error(message?: any, ...optionalParams: any[]): void {\n this.console.error(message, ...optionalParams)\n }\n\n warn(message?: any, ...optionalParams: any[]): void {\n this.console.warn(message, ...optionalParams)\n }\n\n info(message?: any, ...optionalParams: any[]): void {\n this.console.info(message, ...optionalParams)\n }\n}\n"]}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { Writable } from 'node:stream';
|
|
2
|
+
/**
|
|
3
|
+
* A logger that can be used to direct messages to stderr or similar
|
|
4
|
+
* @public
|
|
5
|
+
* @remarks
|
|
6
|
+
* Matches the interface of Node.js Console, for the methods it has.
|
|
7
|
+
*/
|
|
2
8
|
export interface ILogger {
|
|
3
9
|
debug: (message?: any, ...optionalParams: any[]) => void;
|
|
4
10
|
error: (message?: any, ...optionalParams: any[]) => void;
|
|
5
11
|
warn: (message?: any, ...optionalParams: any[]) => void;
|
|
12
|
+
info: (message?: any, ...optionalParams: any[]) => void;
|
|
6
13
|
}
|
|
7
14
|
/**
|
|
8
15
|
* Contextual data about the project environment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/environment/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Writable } from 'node:stream'\n\nexport interface ILogger {\n debug: (message?: any, ...optionalParams: any[]) => void\n error: (message?: any, ...optionalParams: any[]) => void\n warn: (message?: any, ...optionalParams: any[]) => void\n}\n\n/**\n * Contextual data about the project environment\n * @public\n */\nexport interface IRunEnvironment {\n /**\n * Working directory for the project\n * @default process.cwd()\n */\n cwd?: string\n /**\n * Writable stream where the test run's main formatter output is written\n * @default process.stdout\n */\n stdout?: Writable\n /**\n * Writable stream where the test run's warning/error output is written\n * @default process.stderr\n */\n stderr?: Writable\n /**\n * Environment variables\n * @default process.env\n */\n env?: Record<string, string | undefined>\n /**\n * Whether debug logging should be emitted to {@link IRunEnvironment.stderr}\n * @default false\n * @see {@link https://github.com/cucumber/cucumber-js/blob/main/docs/debugging.md}\n */\n debug?: boolean\n}\n\nexport type UsableEnvironment = Required<IRunEnvironment> & {\n logger: ILogger\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/environment/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Writable } from 'node:stream'\n\n/**\n * A logger that can be used to direct messages to stderr or similar\n * @public\n * @remarks\n * Matches the interface of Node.js Console, for the methods it has.\n */\nexport interface ILogger {\n debug: (message?: any, ...optionalParams: any[]) => void\n error: (message?: any, ...optionalParams: any[]) => void\n warn: (message?: any, ...optionalParams: any[]) => void\n info: (message?: any, ...optionalParams: any[]) => void\n}\n\n/**\n * Contextual data about the project environment\n * @public\n */\nexport interface IRunEnvironment {\n /**\n * Working directory for the project\n * @default process.cwd()\n */\n cwd?: string\n /**\n * Writable stream where the test run's main formatter output is written\n * @default process.stdout\n */\n stdout?: Writable\n /**\n * Writable stream where the test run's warning/error output is written\n * @default process.stderr\n */\n stderr?: Writable\n /**\n * Environment variables\n * @default process.env\n */\n env?: Record<string, string | undefined>\n /**\n * Whether debug logging should be emitted to {@link IRunEnvironment.stderr}\n * @default false\n * @see {@link https://github.com/cucumber/cucumber-js/blob/main/docs/debugging.md}\n */\n debug?: boolean\n}\n\nexport type UsableEnvironment = Required<IRunEnvironment> & {\n logger: ILogger\n}\n"]}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const filterPlugin: InternalPlugin<ISourcesCoordinates>;
|
|
1
|
+
import { Plugin } from '../plugin';
|
|
2
|
+
export declare const filterPlugin: Plugin;
|
|
@@ -8,12 +8,12 @@ const pickle_filter_1 = __importDefault(require("../pickle_filter"));
|
|
|
8
8
|
const helpers_1 = require("../cli/helpers");
|
|
9
9
|
exports.filterPlugin = {
|
|
10
10
|
type: 'plugin',
|
|
11
|
-
coordinator: async ({ on, options, logger, environment }) => {
|
|
11
|
+
coordinator: async ({ on, transform, options, logger, environment }) => {
|
|
12
12
|
let unexpandedSourcePaths = [];
|
|
13
13
|
on('paths:resolve', (paths) => {
|
|
14
14
|
unexpandedSourcePaths = paths.unexpandedSourcePaths;
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
transform('pickles:filter', async (allPickles) => {
|
|
17
17
|
const pickleFilter = new pickle_filter_1.default({
|
|
18
18
|
cwd: environment.cwd,
|
|
19
19
|
featurePaths: unexpandedSourcePaths,
|
|
@@ -22,7 +22,7 @@ exports.filterPlugin = {
|
|
|
22
22
|
});
|
|
23
23
|
return allPickles.filter((pickle) => pickleFilter.matches(pickle));
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
transform('pickles:order', async (unorderedPickles) => {
|
|
26
26
|
const orderedPickles = [...unorderedPickles];
|
|
27
27
|
(0, helpers_1.orderPickles)(orderedPickles, options.order, logger);
|
|
28
28
|
return orderedPickles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter_plugin.js","sourceRoot":"","sources":["../../src/filter/filter_plugin.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"filter_plugin.js","sourceRoot":"","sources":["../../src/filter/filter_plugin.ts"],"names":[],"mappings":";;;;;;AACA,qEAA2C;AAC3C,4CAA6C;AAEhC,QAAA,YAAY,GAAW;IAClC,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE;QACrE,IAAI,qBAAqB,GAAa,EAAE,CAAA;QACxC,EAAE,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,qBAAqB,GAAG,KAAK,CAAC,qBAAqB,CAAA;QACrD,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;YAC/C,MAAM,YAAY,GAAG,IAAI,uBAAY,CAAC;gBACpC,GAAG,EAAE,WAAW,CAAC,GAAG;gBACpB,YAAY,EAAE,qBAAqB;gBACnC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,aAAa,EAAE,OAAO,CAAC,aAAa;aACrC,CAAC,CAAA;YAEF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QACpE,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE;YACpD,MAAM,cAAc,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAA;YAC5C,IAAA,sBAAY,EAAC,cAAc,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;YACnD,OAAO,cAAc,CAAA;QACvB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA","sourcesContent":["import { Plugin } from '../plugin'\nimport PickleFilter from '../pickle_filter'\nimport { orderPickles } from '../cli/helpers'\n\nexport const filterPlugin: Plugin = {\n type: 'plugin',\n coordinator: async ({ on, transform, options, logger, environment }) => {\n let unexpandedSourcePaths: string[] = []\n on('paths:resolve', (paths) => {\n unexpandedSourcePaths = paths.unexpandedSourcePaths\n })\n\n transform('pickles:filter', async (allPickles) => {\n const pickleFilter = new PickleFilter({\n cwd: environment.cwd,\n featurePaths: unexpandedSourcePaths,\n names: options.names,\n tagExpression: options.tagExpression,\n })\n\n return allPickles.filter((pickle) => pickleFilter.matches(pickle))\n })\n\n transform('pickles:order', async (unorderedPickles) => {\n const orderedPickles = [...unorderedPickles]\n orderPickles(orderedPickles, options.order, logger)\n return orderedPickles\n })\n },\n}\n"]}
|
package/lib/filter/types.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ import { GherkinDocument, Location, Pickle } from '@cucumber/messages';
|
|
|
8
8
|
* @example "random:234119"
|
|
9
9
|
*/
|
|
10
10
|
export type IPickleOrder = 'defined' | 'reverse' | 'random' | `random:${string}`;
|
|
11
|
+
/**
|
|
12
|
+
* A Pickle decorated with relevant context that can be filtered or sorted
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
11
15
|
export interface IFilterablePickle {
|
|
12
16
|
pickle: Pickle;
|
|
13
17
|
gherkinDocument: GherkinDocument;
|
package/lib/filter/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/filter/types.ts"],"names":[],"mappings":"","sourcesContent":["import { GherkinDocument, Location, Pickle } from '@cucumber/messages'\n\n/**\n * The ordering strategy for pickles\n * @public\n * @example \"defined\"\n * @example \"reverse\"\n * @example \"random\"\n * @example \"random:234119\"\n */\nexport type IPickleOrder = 'defined' | 'reverse' | 'random' | `random:${string}`\n\nexport interface IFilterablePickle {\n pickle: Pickle\n gherkinDocument: GherkinDocument\n location: Location\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/filter/types.ts"],"names":[],"mappings":"","sourcesContent":["import { GherkinDocument, Location, Pickle } from '@cucumber/messages'\n\n/**\n * The ordering strategy for pickles\n * @public\n * @example \"defined\"\n * @example \"reverse\"\n * @example \"random\"\n * @example \"random:234119\"\n */\nexport type IPickleOrder = 'defined' | 'reverse' | 'random' | `random:${string}`\n\n/**\n * A Pickle decorated with relevant context that can be filtered or sorted\n * @public\n */\nexport interface IFilterablePickle {\n pickle: Pickle\n gherkinDocument: GherkinDocument\n location: Location\n}\n"]}
|
|
@@ -112,7 +112,6 @@ class EventDataCollector {
|
|
|
112
112
|
}
|
|
113
113
|
storeAttachment(attachment) {
|
|
114
114
|
const { testCaseStartedId, testStepId } = attachment;
|
|
115
|
-
// TODO: we shouldn't have to check if these properties have values - they are non-nullable
|
|
116
115
|
if ((0, value_checker_1.doesHaveValue)(testCaseStartedId) && (0, value_checker_1.doesHaveValue)(testStepId)) {
|
|
117
116
|
const { stepAttachments } = this.testCaseAttemptDataMap[testCaseStartedId];
|
|
118
117
|
if ((0, value_checker_1.doesNotHaveValue)(stepAttachments[testStepId])) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event_data_collector.js","sourceRoot":"","sources":["../../../src/formatter/helpers/event_data_collector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAA8C;AAC9C,uDAAqE;AAsBrE,MAAqB,kBAAkB;IAC7B,kBAAkB,GAA6C,EAAE,CAAA;IACjE,SAAS,GAAoC,EAAE,CAAA;IAC/C,WAAW,GAAsC,EAAE,CAAA;IACnD,sBAAsB,GAAyC,EAAE,CAAA;IAChE,uBAAuB,GAAsC,EAAE,CAAA;IAExE,YAAY,gBAA8B;QACxC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,kBAAkB,CAAC,GAAW;QAC5B,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC;IAED,SAAS,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IACjC,CAAC;IAED,mBAAmB;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE;YACxE,OAAO,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;QACnD,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,kBAAkB,CAAC,iBAAyB;QAC1C,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAA;QAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,Q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G,MAAM,CAAC,MAAM,CAC/B,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,WAAW,CAC3D,CAAA;QACD,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,mBAAmB;YAChE,QAAQ,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAA;QAC9C,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,aAAa,GAAG,aAAa,CAAA;IAC9E,CAAC;CACF;AA3GD,qCA2GC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, doesNotHaveValue } from '../../value_checker'\n\ninterface ITestCaseAttemptData {\n attempt: number\n willBeRetried: boolean\n testCaseId: string\n stepAttachments: Record<string, messages.Attachment[]>\n stepResults: Record<string, messages.TestStepResult>\n worstTestStepResult: messages.TestStepResult\n}\n\nexport interface ITestCaseAttempt {\n attempt: number\n willBeRetried: boolean\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n stepAttachments: Record<string, messages.Attachment[]>\n stepResults: Record<string, messages.TestStepResult>\n testCase: messages.TestCase\n worstTestStepResult: messages.TestStepResult\n}\n\nexport default class EventDataCollector {\n private gherkinDocumentMap: Record<string, messages.GherkinDocument> = {}\n private pickleMap: Record<string, messages.Pickle> = {}\n private testCaseMap: Record<string, messages.TestCase> = {}\n private testCaseAttemptDataMap: Record<string, ITestCaseAttemptData> = {}\n readonly undefinedParameterTypes: messages.UndefinedParameterType[] = []\n\n constructor(eventBroadcaster: EventEmitter) {\n eventBroadcaster.on('envelope', this.parseEnvelope.bind(this))\n }\n\n getGherkinDocument(uri: string): messages.GherkinDocument {\n return this.gherkinDocumentMap[uri]\n }\n\n getPickle(pickleId: string): messages.Pickle {\n return this.pickleMap[pickleId]\n }\n\n getTestCaseAttempts(): ITestCaseAttempt[] {\n return Object.keys(this.testCaseAttemptDataMap).map((testCaseStartedId) => {\n return this.getTestCaseAttempt(testCaseStartedId)\n })\n }\n\n getTestCaseAttempt(testCaseStartedId: string): ITestCaseAttempt {\n const testCaseAttemptData = this.testCaseAttemptDataMap[testCaseStartedId]\n const testCase = this.testCaseMap[testCaseAttemptData.testCaseId]\n const pickle = this.pickleMap[testCase.pickleId]\n return {\n gherkinDocument: this.gherkinDocumentMap[pickle.uri],\n pickle,\n testCase,\n attempt: testCaseAttemptData.attempt,\n willBeRetried: testCaseAttemptData.willBeRetried,\n stepAttachments: testCaseAttemptData.stepAttachments,\n stepResults: testCaseAttemptData.stepResults,\n worstTestStepResult: testCaseAttemptData.worstTestStepResult,\n }\n }\n\n parseEnvelope(envelope: messages.Envelope): void {\n if (doesHaveValue(envelope.gherkinDocument)) {\n this.gherkinDocumentMap[envelope.gherkinDocument.uri] =\n envelope.gherkinDocument\n } else if (doesHaveValue(envelope.pickle)) {\n this.pickleMap[envelope.pickle.id] = envelope.pickle\n } else if (doesHaveValue(envelope.undefinedParameterType)) {\n this.undefinedParameterTypes.push(envelope.undefinedParameterType)\n } else if (doesHaveValue(envelope.testCase)) {\n this.testCaseMap[envelope.testCase.id] = envelope.testCase\n } else if (doesHaveValue(envelope.testCaseStarted)) {\n this.initTestCaseAttempt(envelope.testCaseStarted)\n } else if (doesHaveValue(envelope.attachment)) {\n this.storeAttachment(envelope.attachment)\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.storeTestStepResult(envelope.testStepFinished)\n } else if (doesHaveValue(envelope.testCaseFinished)) {\n this.storeTestCaseResult(envelope.testCaseFinished)\n }\n }\n\n private initTestCaseAttempt(testCaseStarted: messages.TestCaseStarted): void {\n this.testCaseAttemptDataMap[testCaseStarted.id] = {\n attempt: testCaseStarted.attempt,\n willBeRetried: false,\n testCaseId: testCaseStarted.testCaseId,\n stepAttachments: {},\n stepResults: {},\n worstTestStepResult: {\n duration: { seconds: 0, nanos: 0 },\n status: messages.TestStepResultStatus.UNKNOWN,\n },\n }\n }\n\n storeAttachment(attachment: messages.Attachment): void {\n const { testCaseStartedId, testStepId } = attachment\n if (doesHaveValue(testCaseStartedId) && doesHaveValue(testStepId)) {\n const { stepAttachments } = this.testCaseAttemptDataMap[testCaseStartedId]\n if (doesNotHaveValue(stepAttachments[testStepId])) {\n stepAttachments[testStepId] = []\n }\n stepAttachments[testStepId].push(attachment)\n }\n }\n\n storeTestStepResult({\n testCaseStartedId,\n testStepId,\n testStepResult,\n }: messages.TestStepFinished): void {\n this.testCaseAttemptDataMap[testCaseStartedId].stepResults[testStepId] =\n testStepResult\n }\n\n storeTestCaseResult({\n testCaseStartedId,\n willBeRetried,\n }: messages.TestCaseFinished): void {\n const stepResults = Object.values(\n this.testCaseAttemptDataMap[testCaseStartedId].stepResults\n )\n this.testCaseAttemptDataMap[testCaseStartedId].worstTestStepResult =\n messages.getWorstTestStepResult(stepResults)\n this.testCaseAttemptDataMap[testCaseStartedId].willBeRetried = willBeRetried\n }\n}\n"]}
|
package/lib/paths/types.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths that woll be used to load feature files and user code
|
|
3
|
+
* @public
|
|
4
|
+
* @remarks
|
|
5
|
+
* These values are the result of pre-processing to expand globs, expand
|
|
6
|
+
* directory references, and apply defaults where applicable.
|
|
7
|
+
*/
|
|
1
8
|
export interface IResolvedPaths {
|
|
2
9
|
unexpandedSourcePaths: string[];
|
|
3
10
|
sourcePaths: string[];
|
package/lib/paths/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paths/types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paths/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Paths that woll be used to load feature files and user code\n * @public\n * @remarks\n * These values are the result of pre-processing to expand globs, expand\n * directory references, and apply defaults where applicable.\n */\nexport interface IResolvedPaths {\n unexpandedSourcePaths: string[]\n sourcePaths: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n"]}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { UsableEnvironment } from '../environment';
|
|
2
|
-
import {
|
|
2
|
+
import { CoordinatorEventKey, CoordinatorEventValues, CoordinatorTransformKey, CoordinatorTransformValues, FormatterPlugin, Plugin, PluginOperation } from './types';
|
|
3
3
|
export declare class PluginManager {
|
|
4
4
|
private readonly environment;
|
|
5
|
-
private handlers;
|
|
5
|
+
private readonly handlers;
|
|
6
|
+
private readonly transformers;
|
|
6
7
|
private cleanupFns;
|
|
7
8
|
constructor(environment: UsableEnvironment);
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
private registerHandler;
|
|
10
|
+
private registerTransformer;
|
|
11
|
+
initFormatter<OptionsType>(plugin: FormatterPlugin<OptionsType>, options: OptionsType, stream: NodeJS.WritableStream, write: (buffer: string | Uint8Array) => void, directory?: string, specifier?: string): Promise<void>;
|
|
12
|
+
initCoordinator<OptionsType>(operation: PluginOperation, plugin: Plugin<OptionsType>, options: OptionsType, specifier?: string): Promise<void>;
|
|
13
|
+
emit<K extends CoordinatorEventKey>(event: K, value: CoordinatorEventValues[K]): void;
|
|
14
|
+
transform<K extends CoordinatorTransformKey>(event: K, value: CoordinatorTransformValues[K]): Promise<CoordinatorTransformValues[K]>;
|
|
13
15
|
cleanup(): Promise<void>;
|
|
14
16
|
}
|
|
@@ -6,6 +6,8 @@ class PluginManager {
|
|
|
6
6
|
handlers = {
|
|
7
7
|
message: [],
|
|
8
8
|
'paths:resolve': [],
|
|
9
|
+
};
|
|
10
|
+
transformers = {
|
|
9
11
|
'pickles:filter': [],
|
|
10
12
|
'pickles:order': [],
|
|
11
13
|
};
|
|
@@ -13,12 +15,27 @@ class PluginManager {
|
|
|
13
15
|
constructor(environment) {
|
|
14
16
|
this.environment = environment;
|
|
15
17
|
}
|
|
16
|
-
async
|
|
17
|
-
this.handlers[event]
|
|
18
|
+
async registerHandler(event, handler, specifier) {
|
|
19
|
+
if (!this.handlers[event]) {
|
|
20
|
+
throw new Error(`Cannot register handler for unknown event "${event}"`);
|
|
21
|
+
}
|
|
22
|
+
this.handlers[event].push({
|
|
23
|
+
handler,
|
|
24
|
+
specifier,
|
|
25
|
+
});
|
|
18
26
|
}
|
|
19
|
-
async
|
|
27
|
+
async registerTransformer(event, transformer, specifier) {
|
|
28
|
+
if (!this.transformers[event]) {
|
|
29
|
+
throw new Error(`Cannot register transformer for unknown event "${event}"`);
|
|
30
|
+
}
|
|
31
|
+
this.transformers[event].push({
|
|
32
|
+
transformer,
|
|
33
|
+
specifier,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async initFormatter(plugin, options, stream, write, directory, specifier) {
|
|
20
37
|
const cleanupFn = await plugin.formatter({
|
|
21
|
-
on: (key, handler) => this.
|
|
38
|
+
on: (key, handler) => this.registerHandler(key, handler, specifier),
|
|
22
39
|
options: plugin.optionsKey
|
|
23
40
|
? (options[plugin.optionsKey] ?? {})
|
|
24
41
|
: options,
|
|
@@ -28,32 +45,44 @@ class PluginManager {
|
|
|
28
45
|
directory,
|
|
29
46
|
});
|
|
30
47
|
if (typeof cleanupFn === 'function') {
|
|
31
|
-
this.cleanupFns.push(
|
|
48
|
+
this.cleanupFns.push({
|
|
49
|
+
cleanupFn: cleanupFn,
|
|
50
|
+
specifier,
|
|
51
|
+
});
|
|
32
52
|
}
|
|
33
53
|
}
|
|
34
|
-
async initCoordinator(operation, plugin, options) {
|
|
35
|
-
const
|
|
54
|
+
async initCoordinator(operation, plugin, options, specifier) {
|
|
55
|
+
const context = {
|
|
36
56
|
operation,
|
|
37
|
-
on: this.
|
|
38
|
-
|
|
57
|
+
on: (event, handler) => this.registerHandler(event, handler, specifier),
|
|
58
|
+
transform: (event, transformer) => this.registerTransformer(event, transformer, specifier),
|
|
59
|
+
options: 'optionsKey' in plugin && plugin.optionsKey
|
|
60
|
+
? (options[plugin.optionsKey] ?? {})
|
|
61
|
+
: options,
|
|
39
62
|
logger: this.environment.logger,
|
|
40
63
|
environment: {
|
|
41
64
|
cwd: this.environment.cwd,
|
|
42
65
|
stderr: this.environment.stderr,
|
|
43
66
|
env: { ...this.environment.env },
|
|
44
67
|
},
|
|
45
|
-
}
|
|
68
|
+
};
|
|
69
|
+
const cleanupFn = await wrapErrorAsync(async () => await plugin.coordinator(context), specifier, `Plugin "${specifier}" errored when trying to init`);
|
|
46
70
|
if (typeof cleanupFn === 'function') {
|
|
47
|
-
this.cleanupFns.push(
|
|
71
|
+
this.cleanupFns.push({
|
|
72
|
+
cleanupFn: cleanupFn,
|
|
73
|
+
specifier,
|
|
74
|
+
});
|
|
48
75
|
}
|
|
49
76
|
}
|
|
50
77
|
emit(event, value) {
|
|
51
|
-
this.handlers[event].forEach((handler) =>
|
|
78
|
+
this.handlers[event].forEach(({ handler, specifier }) => {
|
|
79
|
+
wrapError(() => handler(value), specifier, `Plugin "${specifier}" errored when trying to handle a "${event}" event`);
|
|
80
|
+
});
|
|
52
81
|
}
|
|
53
82
|
async transform(event, value) {
|
|
54
83
|
let transformed = value;
|
|
55
|
-
for (const
|
|
56
|
-
const returned = await
|
|
84
|
+
for (const { transformer, specifier } of this.transformers[event]) {
|
|
85
|
+
const returned = await wrapErrorAsync(async () => await transformer(transformed), specifier, `Plugin "${specifier}" errored when trying to do a "${event}" transform`);
|
|
57
86
|
if (typeof returned !== 'undefined') {
|
|
58
87
|
transformed = returned;
|
|
59
88
|
}
|
|
@@ -61,10 +90,32 @@ class PluginManager {
|
|
|
61
90
|
return transformed;
|
|
62
91
|
}
|
|
63
92
|
async cleanup() {
|
|
64
|
-
for (const cleanupFn of this.cleanupFns) {
|
|
65
|
-
await cleanupFn();
|
|
93
|
+
for (const { cleanupFn, specifier } of this.cleanupFns) {
|
|
94
|
+
await wrapErrorAsync(async () => await cleanupFn(), specifier, `Plugin "${specifier}" errored when trying to cleanup`);
|
|
66
95
|
}
|
|
67
96
|
}
|
|
68
97
|
}
|
|
69
98
|
exports.PluginManager = PluginManager;
|
|
99
|
+
function wrapError(fn, specifier, message) {
|
|
100
|
+
try {
|
|
101
|
+
return fn();
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (specifier) {
|
|
105
|
+
throw new Error(message, { cause: error });
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function wrapErrorAsync(fn, specifier, message) {
|
|
111
|
+
try {
|
|
112
|
+
return await fn();
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (specifier) {
|
|
116
|
+
throw new Error(message, { cause: error });
|
|
117
|
+
}
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
70
121
|
//# sourceMappingURL=plugin_manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;;AAqCA,MAAa,aAAa;IAWK;IAVZ,QAAQ,GAAoB;QAC3C,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,EAAE;KACpB,CAAA;IACgB,YAAY,GAAwB;QACnD,gBAAgB,EAAE,EAAE;QACpB,eAAe,EAAE,EAAE;KACpB,CAAA;IACO,UAAU,GAAqB,EAAE,CAAA;IAEzC,YAA6B,WAA8B;QAA9B,gBAAW,GAAX,WAAW,CAAmB;IAAG,CAAC;IAEvD,KAAK,CAAC,eAAe,CAC3B,KAAQ,EACR,OAAmC,EACnC,SAAkB;QAElB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,8CAA8C,KAAK,GAAG,CAAC,CAAA;QACzE,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,C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QACf,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QAC5C,CAAC;QACD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC","sourcesContent":["import { UsableEnvironment } from '../environment'\nimport {\n CoordinatorEventHandler,\n CoordinatorEventKey,\n CoordinatorEventValues,\n CoordinatorTransformer,\n CoordinatorTransformKey,\n CoordinatorTransformValues,\n FormatterPlugin,\n Plugin,\n PluginCleanup,\n PluginOperation,\n} from './types'\n\ntype SourcedEventHandler<K extends CoordinatorEventKey> = {\n handler: CoordinatorEventHandler<K>\n specifier?: string\n}\n\ntype SourcedTransformer<K extends CoordinatorTransformKey> = {\n transformer: CoordinatorTransformer<K>\n specifier?: string\n}\n\ntype SourcedCleanup = {\n cleanupFn: PluginCleanup\n specifier?: string\n}\n\ntype HandlerRegistry = {\n [K in CoordinatorEventKey]: Array<SourcedEventHandler<K>>\n}\n\ntype TransformerRegistry = {\n [K in CoordinatorTransformKey]: Array<SourcedTransformer<K>>\n}\n\nexport class PluginManager {\n private readonly handlers: HandlerRegistry = {\n message: [],\n 'paths:resolve': [],\n }\n private readonly transformers: TransformerRegistry = {\n 'pickles:filter': [],\n 'pickles:order': [],\n }\n private cleanupFns: SourcedCleanup[] = []\n\n constructor(private readonly environment: UsableEnvironment) {}\n\n private async registerHandler<K extends CoordinatorEventKey>(\n event: K,\n handler: CoordinatorEventHandler<K>,\n specifier?: string\n ) {\n if (!this.handlers[event]) {\n throw new Error(`Cannot register handler for unknown event \"${event}\"`)\n }\n this.handlers[event].push({\n handler,\n specifier,\n })\n }\n\n private async registerTransformer<K extends CoordinatorTransformKey>(\n event: K,\n transformer: CoordinatorTransformer<K>,\n specifier?: string\n ) {\n if (!this.transformers[event]) {\n throw new Error(\n `Cannot register transformer for unknown event \"${event}\"`\n )\n }\n this.transformers[event].push({\n transformer,\n specifier,\n })\n }\n\n async initFormatter<OptionsType>(\n plugin: FormatterPlugin<OptionsType>,\n options: OptionsType,\n stream: NodeJS.WritableStream,\n write: (buffer: string | Uint8Array) => void,\n directory?: string,\n specifier?: string\n ) {\n const cleanupFn = await plugin.formatter({\n on: (key, handler) => this.registerHandler(key, handler, specifier),\n options: plugin.optionsKey\n ? ((options as any)[plugin.optionsKey] ?? ({} as OptionsType))\n : options,\n logger: this.environment.logger,\n stream,\n write,\n directory,\n })\n if (typeof cleanupFn === 'function') {\n this.cleanupFns.push({\n cleanupFn: cleanupFn,\n specifier,\n })\n }\n }\n\n async initCoordinator<OptionsType>(\n operation: PluginOperation,\n plugin: Plugin<OptionsType>,\n options: OptionsType,\n specifier?: string\n ) {\n const context = {\n operation,\n on: <K extends CoordinatorEventKey>(\n event: K,\n handler: CoordinatorEventHandler<K>\n ) => this.registerHandler(event, handler, specifier),\n transform: <K extends CoordinatorTransformKey>(\n event: K,\n transformer: CoordinatorTransformer<K>\n ) => this.registerTransformer(event, transformer, specifier),\n options:\n 'optionsKey' in plugin && plugin.optionsKey\n ? ((options as any)[plugin.optionsKey] ?? ({} as OptionsType))\n : options,\n logger: this.environment.logger,\n environment: {\n cwd: this.environment.cwd,\n stderr: this.environment.stderr,\n env: { ...this.environment.env },\n },\n }\n const cleanupFn = await wrapErrorAsync(\n async () => await plugin.coordinator(context),\n specifier,\n `Plugin \"${specifier}\" errored when trying to init`\n )\n if (typeof cleanupFn === 'function') {\n this.cleanupFns.push({\n cleanupFn: cleanupFn,\n specifier,\n })\n }\n }\n\n emit<K extends CoordinatorEventKey>(\n event: K,\n value: CoordinatorEventValues[K]\n ): void {\n this.handlers[event].forEach(({ handler, specifier }) => {\n wrapError(\n () => handler(value),\n specifier,\n `Plugin \"${specifier}\" errored when trying to handle a \"${event}\" event`\n )\n })\n }\n\n async transform<K extends CoordinatorTransformKey>(\n event: K,\n value: CoordinatorTransformValues[K]\n ): Promise<CoordinatorTransformValues[K]> {\n let transformed = value\n for (const { transformer, specifier } of this.transformers[event]) {\n const returned = await wrapErrorAsync(\n async () => await transformer(transformed),\n specifier,\n `Plugin \"${specifier}\" errored when trying to do a \"${event}\" transform`\n )\n if (typeof returned !== 'undefined') {\n transformed = returned\n }\n }\n return transformed\n }\n\n async cleanup(): Promise<void> {\n for (const { cleanupFn, specifier } of this.cleanupFns) {\n await wrapErrorAsync(\n async () => await cleanupFn(),\n specifier,\n `Plugin \"${specifier}\" errored when trying to cleanup`\n )\n }\n }\n}\n\nfunction wrapError<T>(fn: () => T, specifier: string, message: string): T {\n try {\n return fn()\n } catch (error) {\n if (specifier) {\n throw new Error(message, { cause: error })\n }\n throw error\n }\n}\n\nasync function wrapErrorAsync<T>(\n fn: () => Promise<T>,\n specifier: string,\n message: string\n): Promise<T> {\n try {\n return await fn()\n } catch (error) {\n if (specifier) {\n throw new Error(message, { cause: error })\n }\n throw error\n }\n}\n"]}
|
package/lib/plugin/types.d.ts
CHANGED
|
@@ -1,53 +1,141 @@
|
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
1
2
|
import { Envelope } from '@cucumber/messages';
|
|
2
|
-
import { ArrayValues, Promisable } from 'type-fest';
|
|
3
|
-
import { IRunEnvironment } from '../environment';
|
|
4
3
|
import { ILogger } from '../environment';
|
|
5
4
|
import { IFilterablePickle } from '../filter';
|
|
6
5
|
import { IResolvedPaths } from '../paths';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The operation Cucumber is doing in this process
|
|
8
|
+
* @public
|
|
9
|
+
* @remarks
|
|
10
|
+
* `loadSources` and `loadSupport` are generally used as preflight operations
|
|
11
|
+
* for complex use cases. `runCucumber` is the one where tests are actually
|
|
12
|
+
* executed.
|
|
13
|
+
*/
|
|
14
|
+
export type PluginOperation = 'loadSources' | 'loadSupport' | 'runCucumber';
|
|
15
|
+
/**
|
|
16
|
+
* Subset of the environment available to plugins
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export type CoordinatorEnvironment = {
|
|
20
|
+
/**
|
|
21
|
+
* Working directory for the project
|
|
22
|
+
*/
|
|
23
|
+
cwd: string;
|
|
24
|
+
/**
|
|
25
|
+
* Writable stream where the test run's warning/error output is written
|
|
26
|
+
* and plugins can write to directly if required
|
|
27
|
+
*/
|
|
28
|
+
stderr: Writable;
|
|
29
|
+
/**
|
|
30
|
+
* Environment variables
|
|
31
|
+
*/
|
|
32
|
+
env: Record<string, string | undefined>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Keys for event handlers that plugins can register
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export type CoordinatorEventKey = 'message' | 'paths:resolve';
|
|
39
|
+
/**
|
|
40
|
+
* Keys for transforms that plugins can register
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export type CoordinatorTransformKey = 'pickles:filter' | 'pickles:order';
|
|
44
|
+
/**
|
|
45
|
+
* Mapping of event keys to their value types
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export type CoordinatorEventValues = {
|
|
14
49
|
message: Readonly<Envelope>;
|
|
15
50
|
'paths:resolve': Readonly<IResolvedPaths>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Mapping of transform keys to their value types
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export type CoordinatorTransformValues = {
|
|
16
57
|
'pickles:filter': Readonly<Array<IFilterablePickle>>;
|
|
17
58
|
'pickles:order': Readonly<Array<IFilterablePickle>>;
|
|
18
59
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Handler function for a coordinator event
|
|
62
|
+
* @public
|
|
63
|
+
* @remarks
|
|
64
|
+
* You can do async work here, but Cucumber will not await the Promise.
|
|
65
|
+
*/
|
|
66
|
+
export type CoordinatorEventHandler<K extends CoordinatorEventKey> = (value: CoordinatorEventValues[K]) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Transformer function for a coordinator transform
|
|
69
|
+
* @remarks
|
|
70
|
+
* Don't try to modify the original value. Return a transformed value, or
|
|
71
|
+
* `undefined` to pass through unchanged.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export type CoordinatorTransformer<K extends CoordinatorTransformKey> = (value: CoordinatorTransformValues[K]) => PromiseLike<CoordinatorTransformValues[K]> | CoordinatorTransformValues[K];
|
|
75
|
+
/**
|
|
76
|
+
* Context object passed to a plugin's coordinator function
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export type CoordinatorContext<OptionsType> = {
|
|
80
|
+
/**
|
|
81
|
+
* The operation Cucumber is doing in this process
|
|
82
|
+
*/
|
|
83
|
+
operation: PluginOperation;
|
|
84
|
+
/**
|
|
85
|
+
* Register an event handler
|
|
86
|
+
*/
|
|
87
|
+
on: <EventKey extends CoordinatorEventKey>(event: EventKey, handler: CoordinatorEventHandler<EventKey>) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Register a transformer
|
|
90
|
+
*/
|
|
91
|
+
transform: <EventKey extends CoordinatorTransformKey>(event: EventKey, handler: CoordinatorTransformer<EventKey>) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Options for the plugin
|
|
94
|
+
*/
|
|
23
95
|
options: OptionsType;
|
|
96
|
+
/**
|
|
97
|
+
* Logger for emitting user-facing messages or diagnostics
|
|
98
|
+
*/
|
|
24
99
|
logger: ILogger;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Subset of the environment
|
|
102
|
+
*/
|
|
103
|
+
environment: CoordinatorEnvironment;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Optional cleanup function returned by a plugin coordinator
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export type PluginCleanup = () => PromiseLike<void> | void;
|
|
110
|
+
/**
|
|
111
|
+
* A plugin that can subscribe to events and register transforms
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export type Plugin<OptionsType = any> = {
|
|
37
115
|
type: 'plugin';
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Coordinator function called during initialization
|
|
118
|
+
* @remarks
|
|
119
|
+
* Can do async work, and the Promise will be awaited. Can optionally return
|
|
120
|
+
* a cleanup function to be called when Cucumber is about to exit.
|
|
121
|
+
*/
|
|
122
|
+
coordinator: (context: CoordinatorContext<OptionsType>) => PromiseLike<PluginCleanup | void> | PluginCleanup | void;
|
|
123
|
+
/**
|
|
124
|
+
* Optional key to extract plugin-specific options from the root options object
|
|
125
|
+
*/
|
|
126
|
+
optionsKey?: string;
|
|
127
|
+
};
|
|
128
|
+
export type FormatterPluginContext<OptionsType> = {
|
|
41
129
|
on: (key: 'message', handler: (value: Envelope) => void) => void;
|
|
42
130
|
options: OptionsType;
|
|
43
131
|
logger: ILogger;
|
|
44
132
|
stream: NodeJS.WritableStream;
|
|
45
133
|
write: (buffer: string | Uint8Array) => void;
|
|
46
134
|
directory?: string;
|
|
47
|
-
}
|
|
48
|
-
export type FormatterPluginFunction<OptionsType> = (context: FormatterPluginContext<OptionsType>) =>
|
|
49
|
-
export
|
|
135
|
+
};
|
|
136
|
+
export type FormatterPluginFunction<OptionsType> = (context: FormatterPluginContext<OptionsType>) => PromiseLike<PluginCleanup | void> | PluginCleanup | void;
|
|
137
|
+
export type FormatterPlugin<OptionsType = any> = {
|
|
50
138
|
type: 'formatter';
|
|
51
139
|
formatter: FormatterPluginFunction<OptionsType>;
|
|
52
140
|
optionsKey?: string;
|
|
53
|
-
}
|
|
141
|
+
};
|
package/lib/plugin/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Writable } from 'node:stream'\nimport { Envelope } from '@cucumber/messages'\nimport { ILogger } from '../environment'\nimport { IFilterablePickle } from '../filter'\nimport { IResolvedPaths } from '../paths'\n\n/**\n * The operation Cucumber is doing in this process\n * @public\n * @remarks\n * `loadSources` and `loadSupport` are generally used as preflight operations\n * for complex use cases. `runCucumber` is the one where tests are actually\n * executed.\n */\nexport type PluginOperation = 'loadSources' | 'loadSupport' | 'runCucumber'\n\n/**\n * Subset of the environment available to plugins\n * @public\n */\nexport type CoordinatorEnvironment = {\n /**\n * Working directory for the project\n */\n cwd: string\n /**\n * Writable stream where the test run's warning/error output is written\n * and plugins can write to directly if required\n */\n stderr: Writable\n /**\n * Environment variables\n */\n env: Record<string, string | undefined>\n}\n\n/**\n * Keys for event handlers that plugins can register\n * @public\n */\nexport type CoordinatorEventKey = 'message' | 'paths:resolve'\n\n/**\n * Keys for transforms that plugins can register\n * @public\n */\nexport type CoordinatorTransformKey = 'pickles:filter' | 'pickles:order'\n\n/**\n * Mapping of event keys to their value types\n * @public\n */\nexport type CoordinatorEventValues = {\n message: Readonly<Envelope>\n 'paths:resolve': Readonly<IResolvedPaths>\n}\n\n/**\n * Mapping of transform keys to their value types\n * @public\n */\nexport type CoordinatorTransformValues = {\n 'pickles:filter': Readonly<Array<IFilterablePickle>>\n 'pickles:order': Readonly<Array<IFilterablePickle>>\n}\n\n/**\n * Handler function for a coordinator event\n * @public\n * @remarks\n * You can do async work here, but Cucumber will not await the Promise.\n */\nexport type CoordinatorEventHandler<K extends CoordinatorEventKey> = (\n value: CoordinatorEventValues[K]\n) => void\n\n/**\n * Transformer function for a coordinator transform\n * @remarks\n * Don't try to modify the original value. Return a transformed value, or\n * `undefined` to pass through unchanged.\n * @public\n */\nexport type CoordinatorTransformer<K extends CoordinatorTransformKey> = (\n value: CoordinatorTransformValues[K]\n) => PromiseLike<CoordinatorTransformValues[K]> | CoordinatorTransformValues[K]\n\n/**\n * Context object passed to a plugin's coordinator function\n * @public\n */\nexport type CoordinatorContext<OptionsType> = {\n /**\n * The operation Cucumber is doing in this process\n */\n operation: PluginOperation\n /**\n * Register an event handler\n */\n on: <EventKey extends CoordinatorEventKey>(\n event: EventKey,\n handler: CoordinatorEventHandler<EventKey>\n ) => void\n /**\n * Register a transformer\n */\n transform: <EventKey extends CoordinatorTransformKey>(\n event: EventKey,\n handler: CoordinatorTransformer<EventKey>\n ) => void\n /**\n * Options for the plugin\n */\n options: OptionsType\n /**\n * Logger for emitting user-facing messages or diagnostics\n */\n logger: ILogger\n /**\n * Subset of the environment\n */\n environment: CoordinatorEnvironment\n}\n\n/**\n * Optional cleanup function returned by a plugin coordinator\n * @public\n */\nexport type PluginCleanup = () => PromiseLike<void> | void\n\n/**\n * A plugin that can subscribe to events and register transforms\n * @public\n */\nexport type Plugin<OptionsType = any> = {\n type: 'plugin'\n /**\n * Coordinator function called during initialization\n * @remarks\n * Can do async work, and the Promise will be awaited. Can optionally return\n * a cleanup function to be called when Cucumber is about to exit.\n */\n coordinator: (\n context: CoordinatorContext<OptionsType>\n ) => PromiseLike<PluginCleanup | void> | PluginCleanup | void\n /**\n * Optional key to extract plugin-specific options from the root options object\n */\n optionsKey?: string\n}\n\nexport type FormatterPluginContext<OptionsType> = {\n on: (key: 'message', handler: (value: Envelope) => void) => void\n options: OptionsType\n logger: ILogger\n stream: NodeJS.WritableStream\n write: (buffer: string | Uint8Array) => void\n directory?: string\n}\n\nexport type FormatterPluginFunction<OptionsType> = (\n context: FormatterPluginContext<OptionsType>\n) => PromiseLike<PluginCleanup | void> | PluginCleanup | void\n\nexport type FormatterPlugin<OptionsType = any> = {\n type: 'formatter'\n formatter: FormatterPluginFunction<OptionsType>\n optionsKey?: string\n}\n"]}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const publishPlugin: InternalPlugin<IPublishConfig | false>;
|
|
1
|
+
import { Plugin } from '../plugin';
|
|
2
|
+
export declare const publishPlugin: Plugin;
|