@lynxwall/cucumber-tsflow 6.5.7 → 7.1.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 +130 -35
- package/api/index.d.ts +6 -0
- package/bin/cucumber-tsflow +3 -3
- package/bin/cucumber-tsflow.js +3 -0
- package/lib/api/index.d.ts +17 -0
- package/lib/api/index.js +30 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/load-configuration.d.ts +21 -0
- package/lib/api/load-configuration.js +127 -0
- package/lib/api/load-configuration.js.map +1 -0
- package/lib/api/load-support.d.ts +10 -0
- package/lib/api/load-support.js +48 -0
- package/lib/api/load-support.js.map +1 -0
- package/lib/api/run-cucumber.d.ts +16 -0
- package/lib/api/run-cucumber.js +151 -0
- package/lib/api/run-cucumber.js.map +1 -0
- package/lib/api/wrapper.mjs +6 -0
- package/lib/behave.js +19 -9
- package/lib/behave.js.map +1 -0
- package/lib/bindings/binding-context.d.ts +17 -0
- package/lib/bindings/binding-context.js +36 -0
- package/lib/bindings/binding-context.js.map +1 -0
- package/lib/{cucumber → bindings}/binding-decorator.d.ts +2 -2
- package/lib/bindings/binding-decorator.js +201 -0
- package/lib/bindings/binding-decorator.js.map +1 -0
- package/lib/{cucumber → bindings}/binding-registry.d.ts +10 -10
- package/lib/bindings/binding-registry.js +232 -0
- package/lib/bindings/binding-registry.js.map +1 -0
- package/lib/{cucumber → bindings}/hook-decorators.d.ts +6 -6
- package/lib/{cucumber → bindings}/hook-decorators.js +18 -16
- package/lib/bindings/hook-decorators.js.map +1 -0
- package/lib/bindings/step-binding.d.ts +60 -0
- package/lib/bindings/step-binding.js +6 -0
- package/lib/bindings/step-binding.js.map +1 -0
- package/lib/{cucumber/step-definition-decorators.d.ts → bindings/step-decorators.d.ts} +3 -3
- package/lib/bindings/step-decorators.js +97 -0
- package/lib/bindings/step-decorators.js.map +1 -0
- package/lib/bindings/types.d.ts +72 -0
- package/lib/bindings/types.js +58 -0
- package/lib/bindings/types.js.map +1 -0
- package/lib/cli/argv-parser.js +3 -3
- package/lib/cli/argv-parser.js.map +1 -0
- package/lib/cli/index.d.ts +1 -2
- package/lib/cli/index.js +12 -40
- package/lib/cli/index.js.map +1 -0
- package/lib/cli/load-configuration.d.ts +2 -1
- package/lib/cli/load-configuration.js +12 -10
- package/lib/cli/load-configuration.js.map +1 -0
- package/lib/cli/run.js +5 -7
- package/lib/cli/run.js.map +1 -0
- package/lib/cucumber/coordinator.d.ts +15 -0
- package/lib/cucumber/coordinator.js +40 -0
- package/lib/cucumber/coordinator.js.map +1 -0
- package/lib/cucumber/make-runtime.d.ts +12 -16
- package/lib/cucumber/make-runtime.js +10 -33
- package/lib/cucumber/make-runtime.js.map +1 -0
- package/lib/cucumber/managed-scenario-context.d.ts +3 -3
- package/lib/cucumber/managed-scenario-context.js +24 -24
- package/lib/cucumber/managed-scenario-context.js.map +1 -0
- package/lib/cucumber/message-collector.d.ts +3 -0
- package/lib/cucumber/message-collector.js +38 -16
- package/lib/cucumber/message-collector.js.map +1 -0
- package/lib/cucumber/parallel/adapter.d.ts +46 -0
- package/lib/cucumber/parallel/adapter.js +156 -0
- package/lib/cucumber/parallel/adapter.js.map +1 -0
- package/lib/cucumber/parallel/run-worker.d.ts +1 -1
- package/lib/cucumber/parallel/run-worker.js +8 -16
- package/lib/cucumber/parallel/run-worker.js.map +1 -0
- package/lib/cucumber/parallel/worker.d.ts +10 -14
- package/lib/cucumber/parallel/worker.js +59 -68
- package/lib/cucumber/parallel/worker.js.map +1 -0
- package/lib/cucumber/run-cucumber.d.ts +5 -3
- package/lib/cucumber/run-cucumber.js +59 -38
- package/lib/cucumber/run-cucumber.js.map +1 -0
- package/lib/cucumber/serial/adapter.d.ts +12 -0
- package/lib/cucumber/serial/adapter.js +24 -0
- package/lib/cucumber/serial/adapter.js.map +1 -0
- package/lib/cucumber/test-case-info.js +1 -1
- package/lib/cucumber/test-case-info.js.map +1 -0
- package/lib/cucumber/test-case-runner.d.ts +2 -2
- package/lib/cucumber/test-case-runner.js +47 -19
- package/lib/cucumber/test-case-runner.js.map +1 -0
- package/lib/cucumber/utils.js +1 -1
- package/lib/cucumber/utils.js.map +1 -0
- package/lib/cucumber/worker.d.ts +17 -0
- package/lib/cucumber/worker.js +57 -0
- package/lib/cucumber/worker.js.map +1 -0
- package/lib/esnode.d.ts +1 -0
- package/lib/esnode.js +5 -7
- package/lib/esnode.js.map +1 -0
- package/lib/esvue.js +3 -6
- package/lib/esvue.js.map +1 -0
- package/lib/formatter/behave-json-formatter.d.ts +49 -0
- package/lib/formatter/behave-json-formatter.js +85 -0
- package/lib/formatter/behave-json-formatter.js.map +1 -0
- package/lib/formatter/junit-bamboo-formatter.d.ts +17 -0
- package/lib/formatter/junit-bamboo-formatter.js +175 -0
- package/lib/formatter/junit-bamboo-formatter.js.map +1 -0
- package/lib/formatter/step-definition-snippit-syntax/tsflow-snippet-syntax.d.ts +9 -0
- package/lib/formatter/step-definition-snippit-syntax/tsflow-snippet-syntax.js +85 -0
- package/lib/formatter/step-definition-snippit-syntax/tsflow-snippet-syntax.js.map +1 -0
- package/lib/formatters/behave-json-formatter.js +18 -8
- package/lib/formatters/behave-json-formatter.js.map +1 -0
- package/lib/formatters/junit-bamboo-formatter.js +2 -2
- package/lib/formatters/junit-bamboo-formatter.js.map +1 -0
- package/lib/formatters/tsflow-snippet-syntax.js +2 -3
- package/lib/formatters/tsflow-snippet-syntax.js.map +1 -0
- package/lib/gherkin/configuration.d.ts +4 -4
- package/lib/gherkin/configuration.js +1 -1
- package/lib/gherkin/configuration.js.map +1 -0
- package/lib/gherkin/gherkin-feature.js +18 -8
- package/lib/gherkin/gherkin-feature.js.map +1 -0
- package/lib/gherkin/gherkin-manager.js +2 -2
- package/lib/gherkin/gherkin-manager.js.map +1 -0
- package/lib/gherkin/models.d.ts +1 -1
- package/lib/gherkin/models.js +1 -1
- package/lib/gherkin/models.js.map +1 -0
- package/lib/index.d.ts +42 -5
- package/lib/index.js +114 -8
- package/lib/index.js.map +1 -0
- package/lib/junitbamboo.js +19 -9
- package/lib/junitbamboo.js.map +1 -0
- package/lib/runtime/coordinator.d.ts +15 -0
- package/lib/runtime/coordinator.js +40 -0
- package/lib/runtime/coordinator.js.map +1 -0
- package/lib/runtime/make-runtime.d.ts +22 -0
- package/lib/runtime/make-runtime.js +17 -0
- package/lib/runtime/make-runtime.js.map +1 -0
- package/lib/runtime/managed-scenario-context.d.ts +52 -0
- package/lib/runtime/managed-scenario-context.js +149 -0
- package/lib/runtime/managed-scenario-context.js.map +1 -0
- package/lib/runtime/message-collector.d.ts +98 -0
- package/lib/runtime/message-collector.js +284 -0
- package/lib/runtime/message-collector.js.map +1 -0
- package/lib/runtime/parallel/adapter.d.ts +47 -0
- package/lib/runtime/parallel/adapter.js +159 -0
- package/lib/runtime/parallel/adapter.js.map +1 -0
- package/lib/runtime/parallel/run-worker.d.ts +1 -0
- package/lib/runtime/parallel/run-worker.js +24 -0
- package/lib/runtime/parallel/run-worker.js.map +1 -0
- package/lib/runtime/parallel/types.d.ts +13 -0
- package/lib/runtime/parallel/types.js +3 -0
- package/lib/runtime/parallel/types.js.map +1 -0
- package/lib/runtime/parallel/worker.d.ts +44 -0
- package/lib/runtime/parallel/worker.js +118 -0
- package/lib/runtime/parallel/worker.js.map +1 -0
- package/lib/runtime/scenario-context.d.ts +16 -0
- package/lib/runtime/scenario-context.js +18 -0
- package/lib/runtime/scenario-context.js.map +1 -0
- package/lib/runtime/scenario-info.d.ts +16 -0
- package/lib/runtime/scenario-info.js +23 -0
- package/lib/runtime/scenario-info.js.map +1 -0
- package/lib/runtime/serial/adapter.d.ts +12 -0
- package/lib/runtime/serial/adapter.js +24 -0
- package/lib/runtime/serial/adapter.js.map +1 -0
- package/lib/runtime/test-case-info.d.ts +23 -0
- package/lib/runtime/test-case-info.js +3 -0
- package/lib/runtime/test-case-info.js.map +1 -0
- package/lib/runtime/test-case-runner.d.ts +48 -0
- package/lib/runtime/test-case-runner.js +345 -0
- package/lib/runtime/test-case-runner.js.map +1 -0
- package/lib/runtime/utils.d.ts +16 -0
- package/lib/runtime/utils.js +78 -0
- package/lib/runtime/utils.js.map +1 -0
- package/lib/runtime/worker.d.ts +17 -0
- package/lib/runtime/worker.js +57 -0
- package/lib/runtime/worker.js.map +1 -0
- package/lib/snippet.js +20 -10
- package/lib/snippet.js.map +1 -0
- package/lib/transpilers/esbuild-transpiler.d.ts +1 -1
- package/lib/transpilers/esbuild-transpiler.js +1 -1
- package/lib/transpilers/esbuild-transpiler.js.map +1 -0
- package/lib/transpilers/esbuild.js +4 -4
- package/lib/transpilers/esbuild.js.map +1 -0
- package/lib/transpilers/vue-sfc/compiler.js +1 -1
- package/lib/transpilers/vue-sfc/compiler.js.map +1 -0
- package/lib/transpilers/vue-sfc/index.d.ts +4 -4
- package/lib/transpilers/vue-sfc/index.js +1 -2
- package/lib/transpilers/vue-sfc/index.js.map +1 -0
- package/lib/transpilers/vue-sfc/main.d.ts +1 -1
- package/lib/transpilers/vue-sfc/main.js +1 -1
- package/lib/transpilers/vue-sfc/main.js.map +1 -0
- package/lib/transpilers/vue-sfc/script.js +1 -2
- package/lib/transpilers/vue-sfc/script.js.map +1 -0
- package/lib/transpilers/vue-sfc/template.d.ts +1 -1
- package/lib/transpilers/vue-sfc/template.js +2 -3
- package/lib/transpilers/vue-sfc/template.js.map +1 -0
- package/lib/transpilers/vue-sfc/types.d.ts +2 -2
- package/lib/transpilers/vue-sfc/types.js +1 -1
- package/lib/transpilers/vue-sfc/types.js.map +1 -0
- package/lib/transpilers/vue-sfc/utils/descriptorCache.js +1 -1
- package/lib/transpilers/vue-sfc/utils/descriptorCache.js.map +1 -0
- package/lib/transpilers/vue-sfc/utils/error.js +1 -1
- package/lib/transpilers/vue-sfc/utils/error.js.map +1 -0
- package/lib/transpilers/vue-sfc/utils/query.js +1 -1
- package/lib/transpilers/vue-sfc/utils/query.js.map +1 -0
- package/lib/tsconfig.node.tsbuildinfo +1 -0
- package/lib/tsnode.d.ts +1 -0
- package/lib/tsnode.js +4 -6
- package/lib/tsnode.js.map +1 -0
- package/lib/tsvue.js +3 -6
- package/lib/tsvue.js.map +1 -0
- package/lib/types/parallel.d.ts +11 -0
- package/lib/types/parallel.js +3 -0
- package/lib/types/parallel.js.map +1 -0
- package/lib/types/scenario-context.js +1 -1
- package/lib/types/scenario-context.js.map +1 -0
- package/lib/types/scenario-info.js +1 -1
- package/lib/types/scenario-info.js.map +1 -0
- package/lib/types/step-binding-flags.js +1 -1
- package/lib/types/step-binding-flags.js.map +1 -0
- package/lib/types/step-binding.d.ts +30 -20
- package/lib/types/step-binding.js +1 -1
- package/lib/types/step-binding.js.map +1 -0
- package/lib/types/types.js +1 -1
- package/lib/types/types.js.map +1 -0
- package/lib/utils/helpers.js +1 -1
- package/lib/utils/helpers.js.map +1 -0
- package/lib/utils/logger.d.ts +2 -2
- package/lib/utils/logger.js +7 -26
- package/lib/utils/logger.js.map +1 -0
- package/lib/utils/our-callsite.js +18 -8
- package/lib/utils/our-callsite.js.map +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +2 -2
- package/lib/version.js.map +1 -0
- package/lib/wrapper.mjs +56 -0
- package/package.json +65 -27
- package/lib/cucumber/binding-decorator.js +0 -181
- package/lib/cucumber/binding-registry.js +0 -231
- package/lib/cucumber/parallel/coordinator.d.ts +0 -79
- package/lib/cucumber/parallel/coordinator.js +0 -247
- package/lib/cucumber/runtime.d.ts +0 -40
- package/lib/cucumber/runtime.js +0 -85
- package/lib/cucumber/step-definition-decorators.js +0 -92
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Worker = void 0;
|
|
7
|
+
const test_case_runner_1 = __importDefault(require("./test-case-runner"));
|
|
8
|
+
const helpers_1 = require("@cucumber/cucumber/lib/runtime/helpers");
|
|
9
|
+
const run_test_run_hooks_1 = require("@cucumber/cucumber/lib/runtime/run_test_run_hooks");
|
|
10
|
+
class Worker {
|
|
11
|
+
workerId;
|
|
12
|
+
eventBroadcaster;
|
|
13
|
+
newId;
|
|
14
|
+
options;
|
|
15
|
+
supportCodeLibrary;
|
|
16
|
+
runTestRunHooks;
|
|
17
|
+
constructor(workerId, eventBroadcaster, newId, options, supportCodeLibrary) {
|
|
18
|
+
this.workerId = workerId;
|
|
19
|
+
this.eventBroadcaster = eventBroadcaster;
|
|
20
|
+
this.newId = newId;
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.supportCodeLibrary = supportCodeLibrary;
|
|
23
|
+
this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(this.options.dryRun, this.supportCodeLibrary.defaultTimeout, this.options.worldParameters, (name, location) => {
|
|
24
|
+
let message = `${name} hook errored`;
|
|
25
|
+
if (this.workerId) {
|
|
26
|
+
message += ` on worker ${this.workerId}`;
|
|
27
|
+
}
|
|
28
|
+
message += `, process exiting: ${location}`;
|
|
29
|
+
return message;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async runBeforeAllHooks() {
|
|
33
|
+
await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
|
|
34
|
+
}
|
|
35
|
+
async runTestCase({ gherkinDocument, pickle, testCase }, failing) {
|
|
36
|
+
const testCaseRunner = new test_case_runner_1.default({
|
|
37
|
+
workerId: this.workerId,
|
|
38
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
39
|
+
newId: this.newId,
|
|
40
|
+
gherkinDocument,
|
|
41
|
+
pickle,
|
|
42
|
+
testCase,
|
|
43
|
+
retries: (0, helpers_1.retriesForPickle)(pickle, this.options),
|
|
44
|
+
skip: this.options.dryRun || (this.options.failFast && failing),
|
|
45
|
+
filterStackTraces: this.options.filterStacktraces,
|
|
46
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
47
|
+
worldParameters: this.options.worldParameters
|
|
48
|
+
});
|
|
49
|
+
const status = await testCaseRunner.run();
|
|
50
|
+
return !(0, helpers_1.shouldCauseFailure)(status, this.options);
|
|
51
|
+
}
|
|
52
|
+
async runAfterAllHooks() {
|
|
53
|
+
await this.runTestRunHooks(this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(), 'an AfterAll');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.Worker = Worker;
|
|
57
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/cucumber/worker.ts"],"names":[],"mappings":";;;;;;AAIA,0EAAgD;AAChD,oEAA8F;AAC9F,0FAA0G;AAG1G,MAAa,MAAM;IAIA;IACA;IACA;IACA;IACA;IAPD,eAAe,CAAmB;IAEnD,YACkB,QAA4B,EAC5B,gBAA8B,EAC9B,KAAwB,EACxB,OAAuB,EACvB,kBAAsC;QAJtC,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,qBAAgB,GAAhB,gBAAgB,CAAc;QAC9B,UAAK,GAAL,KAAK,CAAmB;QACxB,YAAO,GAAP,OAAO,CAAgB;QACvB,uBAAkB,GAAlB,kBAAkB,CAAoB;QAEvD,IAAI,CAAC,eAAe,GAAG,IAAA,wCAAmB,EACzC,IAAI,CAAC,OAAO,CAAC,MAAM,EACnB,IAAI,CAAC,kBAAkB,CAAC,cAAc,EACtC,IAAI,CAAC,OAAO,CAAC,eAAe,EAC5B,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;YAClB,IAAI,OAAO,GAAG,GAAG,IAAI,eAAe,CAAC;YACrC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,OAAO,IAAI,cAAc,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1C,CAAC;YACD,OAAO,IAAI,sBAAsB,QAAQ,EAAE,CAAC;YAC5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nimport { AssembledTestCase } from '@cucumber/cucumber/lib/assemble/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport TestCaseRunner from './test-case-runner';\r\nimport { retriesForPickle, shouldCauseFailure } from '@cucumber/cucumber/lib/runtime/helpers';\r\nimport { makeRunTestRunHooks, RunsTestRunHooks } from '@cucumber/cucumber/lib/runtime/run_test_run_hooks';\r\nimport { RuntimeOptions } from '@cucumber/cucumber/lib/runtime/index';\r\n\r\nexport class Worker {\r\n\tprivate readonly runTestRunHooks: RunsTestRunHooks;\r\n\r\n\tconstructor(\r\n\t\tprivate readonly workerId: string | undefined,\r\n\t\tprivate readonly eventBroadcaster: EventEmitter,\r\n\t\tprivate readonly newId: IdGenerator.NewId,\r\n\t\tprivate readonly options: RuntimeOptions,\r\n\t\tprivate readonly supportCodeLibrary: SupportCodeLibrary\r\n\t) {\r\n\t\tthis.runTestRunHooks = makeRunTestRunHooks(\r\n\t\t\tthis.options.dryRun,\r\n\t\t\tthis.supportCodeLibrary.defaultTimeout,\r\n\t\t\tthis.options.worldParameters,\r\n\t\t\t(name, location) => {\r\n\t\t\t\tlet message = `${name} hook errored`;\r\n\t\t\t\tif (this.workerId) {\r\n\t\t\t\t\tmessage += ` on worker ${this.workerId}`;\r\n\t\t\t\t}\r\n\t\t\t\tmessage += `, process exiting: ${location}`;\r\n\t\t\t\treturn message;\r\n\t\t\t}\r\n\t\t);\r\n\t}\r\n\r\n\tasync runBeforeAllHooks() {\r\n\t\tawait this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');\r\n\t}\r\n\r\n\tasync runTestCase({ gherkinDocument, pickle, testCase }: AssembledTestCase, failing: boolean): Promise<boolean> {\r\n\t\tconst testCaseRunner = new TestCaseRunner({\r\n\t\t\tworkerId: this.workerId,\r\n\t\t\teventBroadcaster: this.eventBroadcaster,\r\n\t\t\tnewId: this.newId,\r\n\t\t\tgherkinDocument,\r\n\t\t\tpickle,\r\n\t\t\ttestCase,\r\n\t\t\tretries: retriesForPickle(pickle, this.options),\r\n\t\t\tskip: this.options.dryRun || (this.options.failFast && failing),\r\n\t\t\tfilterStackTraces: this.options.filterStacktraces,\r\n\t\t\tsupportCodeLibrary: this.supportCodeLibrary,\r\n\t\t\tworldParameters: this.options.worldParameters\r\n\t\t});\r\n\r\n\t\tconst status = await testCaseRunner.run();\r\n\r\n\t\treturn !shouldCauseFailure(status, this.options);\r\n\t}\r\n\r\n\tasync runAfterAllHooks() {\r\n\t\tawait this.runTestRunHooks(this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(), 'an AfterAll');\r\n\t}\r\n}\r\n"]}
|
package/lib/esnode.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esnode.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
require('ts-node').register({
|
|
3
4
|
compilerOptions: {
|
|
4
|
-
module: '
|
|
5
|
-
|
|
6
|
-
target: 'es2020',
|
|
5
|
+
module: 'nodeNext',
|
|
6
|
+
target: 'es2022',
|
|
7
7
|
strict: true,
|
|
8
|
-
experimentalDecorators: true,
|
|
9
|
-
allowSyntheticDefaultImports: true,
|
|
10
8
|
resolveJsonModule: true,
|
|
11
9
|
esModuleInterop: true,
|
|
12
10
|
skipLibCheck: true,
|
|
13
|
-
lib: ['
|
|
11
|
+
lib: ['es2022', 'esnext.decorators']
|
|
14
12
|
},
|
|
15
13
|
transpileOnly: true,
|
|
16
14
|
transpiler: '@lynxwall/cucumber-tsflow/lib/transpilers/esbuild-transpiler'
|
|
17
15
|
});
|
|
18
16
|
require('tsconfig-paths').register();
|
|
19
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=esnode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esnode.js","sourceRoot":"","sources":["../src/esnode.ts"],"names":[],"mappings":";;AAAA,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC;IAC3B,eAAe,EAAE;QAChB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,IAAI;QACZ,iBAAiB,EAAE,IAAI;QACvB,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,IAAI;QAClB,GAAG,EAAE,CAAC,QAAQ,EAAE,mBAAmB,CAAC;KACpC;IACD,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,8DAA8D;CAC1E,CAAC,CAAC;AAEH,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["require('ts-node').register({\r\n\tcompilerOptions: {\r\n\t\tmodule: 'nodeNext',\r\n\t\ttarget: 'es2022',\r\n\t\tstrict: true,\r\n\t\tresolveJsonModule: true,\r\n\t\tesModuleInterop: true,\r\n\t\tskipLibCheck: true,\r\n\t\tlib: ['es2022', 'esnext.decorators']\r\n\t},\r\n\ttranspileOnly: true,\r\n\ttranspiler: '@lynxwall/cucumber-tsflow/lib/transpilers/esbuild-transpiler'\r\n});\r\n\r\nrequire('tsconfig-paths').register();\r\n"]}
|
package/lib/esvue.js
CHANGED
|
@@ -7,16 +7,13 @@ const hooks = require('require-extension-hooks');
|
|
|
7
7
|
const vue_sfc_1 = __importDefault(require("./transpilers/vue-sfc"));
|
|
8
8
|
require('ts-node').register({
|
|
9
9
|
compilerOptions: {
|
|
10
|
-
module: '
|
|
11
|
-
moduleResolution: 'node',
|
|
10
|
+
module: 'nodeNext',
|
|
12
11
|
target: 'es2022',
|
|
13
12
|
strict: true,
|
|
14
|
-
experimentalDecorators: true,
|
|
15
|
-
allowSyntheticDefaultImports: true,
|
|
16
13
|
resolveJsonModule: true,
|
|
17
14
|
esModuleInterop: true,
|
|
18
15
|
skipLibCheck: true,
|
|
19
|
-
lib: ['es2022']
|
|
16
|
+
lib: ['es2022', 'esnext.decorators']
|
|
20
17
|
},
|
|
21
18
|
transpileOnly: true,
|
|
22
19
|
transpiler: '@lynxwall/cucumber-tsflow/lib/transpilers/esbuild-transpiler'
|
|
@@ -38,4 +35,4 @@ hooks('vue').push(function (params) {
|
|
|
38
35
|
}
|
|
39
36
|
return params.content;
|
|
40
37
|
});
|
|
41
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=esvue.js.map
|
package/lib/esvue.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esvue.js","sourceRoot":"","sources":["../src/esvue.ts"],"names":[],"mappings":";;;;;AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACjD,oEAAmD;AAEnD,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC;IAC3B,eAAe,EAAE;QAChB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,IAAI;QACZ,iBAAiB,EAAE,IAAI;QACvB,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,IAAI;QAClB,GAAG,EAAE,CAAC,QAAQ,EAAE,mBAAmB,CAAC;KACpC;IACD,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,8DAA8D;CAC1E,CAAC,CAAC;AAEH,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC;AAErC,uDAAuD;AACvD,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;AACzB,MAAc,CAAC,UAAU,GAAI,MAAc,CAAC,MAAM,CAAC,UAAU,CAAC;AAE/D,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,MAAW;IACtC,IAAI,CAAC;QACJ,MAAM,WAAW,GAAG,IAAI,iBAAc,CAAC;YACtC,OAAO,EAAE,CAAC,sBAAsB,EAAE,6BAA6B,CAAC;SAChE,CAAC,CAAC;QACH,MAAM,eAAe,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEnF,OAAO,eAAe,CAAC,IAAI,CAAC;IAC7B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["const hooks = require('require-extension-hooks');\r\nimport VueTransformer from './transpilers/vue-sfc';\r\n\r\nrequire('ts-node').register({\r\n\tcompilerOptions: {\r\n\t\tmodule: 'nodeNext',\r\n\t\ttarget: 'es2022',\r\n\t\tstrict: true,\r\n\t\tresolveJsonModule: true,\r\n\t\tesModuleInterop: true,\r\n\t\tskipLibCheck: true,\r\n\t\tlib: ['es2022', 'esnext.decorators']\r\n\t},\r\n\ttranspileOnly: true,\r\n\ttranspiler: '@lynxwall/cucumber-tsflow/lib/transpilers/esbuild-transpiler'\r\n});\r\n\r\nrequire('tsconfig-paths').register();\r\n\r\n// Register jsdom globally and set SVGElement on global\r\nrequire('jsdom-global')();\r\n(global as any).SVGElement = (global as any).window.SVGElement;\r\n\r\nhooks('vue').push(function (params: any) {\r\n\ttry {\r\n\t\tconst transformer = new VueTransformer({\r\n\t\t\texclude: ['(?:^|/)node_modules/', '(?:^|/)cucumber-tsflow/lib/']\r\n\t\t});\r\n\t\tconst transformResult = transformer.transformCode(params.content, params.filename);\r\n\r\n\t\treturn transformResult.code;\r\n\t} catch (err) {\r\n\t\tconsole.log(err);\r\n\t}\r\n\treturn params.content;\r\n});\r\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
|
+
import JsonFormatter from '@cucumber/cucumber/lib/formatter/json_formatter';
|
|
3
|
+
export interface IJsonFeature {
|
|
4
|
+
description: string;
|
|
5
|
+
elements: IJsonScenario[];
|
|
6
|
+
id: string;
|
|
7
|
+
keyword: string;
|
|
8
|
+
line: number;
|
|
9
|
+
name: string;
|
|
10
|
+
tags: IJsonTag[];
|
|
11
|
+
uri: string;
|
|
12
|
+
}
|
|
13
|
+
export interface IJsonScenario {
|
|
14
|
+
description: string;
|
|
15
|
+
id: string;
|
|
16
|
+
keyword: string;
|
|
17
|
+
line: number;
|
|
18
|
+
name: string;
|
|
19
|
+
steps: IJsonStep[];
|
|
20
|
+
tags: IJsonTag[];
|
|
21
|
+
type: string;
|
|
22
|
+
}
|
|
23
|
+
export interface IJsonStep {
|
|
24
|
+
arguments?: any;
|
|
25
|
+
embeddings?: any;
|
|
26
|
+
hidden?: boolean;
|
|
27
|
+
keyword?: string;
|
|
28
|
+
line?: number;
|
|
29
|
+
match?: any;
|
|
30
|
+
name?: string;
|
|
31
|
+
result?: any;
|
|
32
|
+
}
|
|
33
|
+
export interface IJsonTag {
|
|
34
|
+
name: string;
|
|
35
|
+
line: number;
|
|
36
|
+
}
|
|
37
|
+
interface IBuildJsonStepOptions {
|
|
38
|
+
isBeforeHook: boolean;
|
|
39
|
+
gherkinStepMap: Record<string, messages.Step>;
|
|
40
|
+
pickleStepMap: Record<string, messages.PickleStep>;
|
|
41
|
+
testStep: messages.TestStep;
|
|
42
|
+
testStepAttachments: messages.Attachment[];
|
|
43
|
+
testStepResult: messages.TestStepResult;
|
|
44
|
+
}
|
|
45
|
+
export default class BehaveJsonFormatter extends JsonFormatter {
|
|
46
|
+
static readonly documentation: string;
|
|
47
|
+
getStepData({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult }: IBuildJsonStepOptions): IJsonStep;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const index_1 = require("@cucumber/cucumber/lib/formatter/helpers/index");
|
|
40
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
41
|
+
const value_checker_1 = require("@cucumber/cucumber/lib/value_checker");
|
|
42
|
+
const json_formatter_1 = __importDefault(require("@cucumber/cucumber/lib/formatter/json_formatter"));
|
|
43
|
+
const { getStepKeyword } = index_1.PickleParser;
|
|
44
|
+
class BehaveJsonFormatter extends json_formatter_1.default {
|
|
45
|
+
static documentation = 'Prints the feature as JSON that can be used with Behave Pro';
|
|
46
|
+
getStepData({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult }) {
|
|
47
|
+
const data = {};
|
|
48
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId)) {
|
|
49
|
+
const pickleStep = pickleStepMap[testStep.pickleStepId];
|
|
50
|
+
data.arguments = this.formatStepArgument(pickleStep.argument, gherkinStepMap[pickleStep.astNodeIds[0]]);
|
|
51
|
+
data.keyword = getStepKeyword({ pickleStep, gherkinStepMap });
|
|
52
|
+
data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line;
|
|
53
|
+
data.name = pickleStep.text;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
data.keyword = isBeforeHook ? 'Before' : 'After';
|
|
57
|
+
data.hidden = true;
|
|
58
|
+
data.name = '';
|
|
59
|
+
}
|
|
60
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.stepDefinitionIds) && testStep.stepDefinitionIds?.length === 1) {
|
|
61
|
+
const stepDefinitionId = testStep.stepDefinitionIds[0];
|
|
62
|
+
const stepDefinition = this.supportCodeLibrary.stepDefinitions.find(s => s.id === stepDefinitionId);
|
|
63
|
+
data.match = { location: (0, index_1.formatLocation)(stepDefinition) };
|
|
64
|
+
}
|
|
65
|
+
const { message, status } = testStepResult;
|
|
66
|
+
data.result = {
|
|
67
|
+
status: messages.TestStepResultStatus[status].toLowerCase()
|
|
68
|
+
};
|
|
69
|
+
if ((0, value_checker_1.doesHaveValue)(testStepResult.duration)) {
|
|
70
|
+
data.result.duration = messages.TimeConversion.durationToMilliseconds(testStepResult.duration) * 1000000;
|
|
71
|
+
}
|
|
72
|
+
if (status === messages.TestStepResultStatus.FAILED && (0, value_checker_1.doesHaveValue)(message)) {
|
|
73
|
+
data.result.error_message = message;
|
|
74
|
+
}
|
|
75
|
+
if (testStepAttachments?.length > 0) {
|
|
76
|
+
data.embeddings = testStepAttachments.map(attachment => ({
|
|
77
|
+
data: attachment.body,
|
|
78
|
+
mime_type: attachment.mediaType
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.default = BehaveJsonFormatter;
|
|
85
|
+
//# sourceMappingURL=behave-json-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behave-json-formatter.js","sourceRoot":"","sources":["../../src/formatter/behave-json-formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA8F;AAC9F,6DAA+C;AAC/C,wEAAqE;AACrE,qGAA4E;AAE5E,MAAM,EAAE,cAAc,EAAE,GAAG,oBAAY,CAAC;AA+CxC,MAAqB,mBAAoB,SAAQ,wBAAa;IACtD,MAAM,CAAU,aAAa,GAAW,6DAA6D,CAAC;IAE7G,WAAW,CAAC,EACX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,QAAQ,EACR,mBAAmB,EACnB,cAAc,EACS;QACvB,MAAM,IAAI,GAAc,EAAE,CAAC;QAC3B,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YAC1C,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,YAAsB,CAAC,CAAC;YAClE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CACvC,UAAU,CAAC,QAAuC,EAClD,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACxC,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;YAC9D,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,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/E,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC;QACrC,CAAC;QACD,IAAI,mBAAmB,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;gBACxD,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,SAAS,EAAE,UAAU,CAAC,SAAS;aAC/B,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;;AAhDF,sCAiDC","sourcesContent":["import { formatLocation, PickleParser } from '@cucumber/cucumber/lib/formatter/helpers/index';\r\nimport * as messages from '@cucumber/messages';\r\nimport { doesHaveValue } from '@cucumber/cucumber/lib/value_checker';\r\nimport JsonFormatter from '@cucumber/cucumber/lib/formatter/json_formatter';\r\nimport { ILineAndUri } from '@cucumber/cucumber/lib/types/index';\r\nconst { getStepKeyword } = PickleParser;\r\n\r\nexport interface IJsonFeature {\r\n\tdescription: string;\r\n\telements: IJsonScenario[];\r\n\tid: string;\r\n\tkeyword: string;\r\n\tline: number;\r\n\tname: string;\r\n\ttags: IJsonTag[];\r\n\turi: string;\r\n}\r\n\r\nexport interface IJsonScenario {\r\n\tdescription: string;\r\n\tid: string;\r\n\tkeyword: string;\r\n\tline: number;\r\n\tname: string;\r\n\tsteps: IJsonStep[];\r\n\ttags: IJsonTag[];\r\n\ttype: string;\r\n}\r\n\r\nexport interface IJsonStep {\r\n\targuments?: any; // TODO\r\n\tembeddings?: any; // TODO\r\n\thidden?: boolean;\r\n\tkeyword?: string; // TODO, not optional\r\n\tline?: number;\r\n\tmatch?: any; // TODO\r\n\tname?: string;\r\n\tresult?: any; // TODO\r\n}\r\n\r\nexport interface IJsonTag {\r\n\tname: string;\r\n\tline: number;\r\n}\r\ninterface IBuildJsonStepOptions {\r\n\tisBeforeHook: boolean;\r\n\tgherkinStepMap: Record<string, messages.Step>;\r\n\tpickleStepMap: Record<string, messages.PickleStep>;\r\n\ttestStep: messages.TestStep;\r\n\ttestStepAttachments: messages.Attachment[];\r\n\ttestStepResult: messages.TestStepResult;\r\n}\r\nexport default class BehaveJsonFormatter extends JsonFormatter {\r\n\tpublic static readonly documentation: string = 'Prints the feature as JSON that can be used with Behave Pro';\r\n\r\n\tgetStepData({\r\n\t\tisBeforeHook,\r\n\t\tgherkinStepMap,\r\n\t\tpickleStepMap,\r\n\t\ttestStep,\r\n\t\ttestStepAttachments,\r\n\t\ttestStepResult\r\n\t}: IBuildJsonStepOptions): IJsonStep {\r\n\t\tconst data: IJsonStep = {};\r\n\t\tif (doesHaveValue(testStep.pickleStepId)) {\r\n\t\t\tconst pickleStep = pickleStepMap[testStep.pickleStepId as string];\r\n\t\t\tdata.arguments = this.formatStepArgument(\r\n\t\t\t\tpickleStep.argument as messages.PickleStepArgument,\r\n\t\t\t\tgherkinStepMap[pickleStep.astNodeIds[0]]\r\n\t\t\t);\r\n\t\t\tdata.keyword = getStepKeyword({ pickleStep, gherkinStepMap });\r\n\t\t\tdata.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line;\r\n\t\t\tdata.name = pickleStep.text;\r\n\t\t} else {\r\n\t\t\tdata.keyword = isBeforeHook ? 'Before' : 'After';\r\n\t\t\tdata.hidden = true;\r\n\t\t\tdata.name = '';\r\n\t\t}\r\n\t\tif (doesHaveValue(testStep.stepDefinitionIds) && testStep.stepDefinitionIds?.length === 1) {\r\n\t\t\tconst stepDefinitionId = testStep.stepDefinitionIds[0];\r\n\t\t\tconst stepDefinition = this.supportCodeLibrary.stepDefinitions.find(s => s.id === stepDefinitionId);\r\n\t\t\tdata.match = { location: formatLocation(stepDefinition as ILineAndUri) };\r\n\t\t}\r\n\t\tconst { message, status } = testStepResult;\r\n\t\tdata.result = {\r\n\t\t\tstatus: messages.TestStepResultStatus[status].toLowerCase()\r\n\t\t};\r\n\t\tif (doesHaveValue(testStepResult.duration)) {\r\n\t\t\tdata.result.duration = messages.TimeConversion.durationToMilliseconds(testStepResult.duration) * 1000000;\r\n\t\t}\r\n\t\tif (status === messages.TestStepResultStatus.FAILED && doesHaveValue(message)) {\r\n\t\t\tdata.result.error_message = message;\r\n\t\t}\r\n\t\tif (testStepAttachments?.length > 0) {\r\n\t\t\tdata.embeddings = testStepAttachments.map(attachment => ({\r\n\t\t\t\tdata: attachment.body,\r\n\t\t\t\tmime_type: attachment.mediaType\r\n\t\t\t}));\r\n\t\t}\r\n\t\treturn data;\r\n\t}\r\n}\r\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Formatter, IFormatterOptions } from '@cucumber/cucumber';
|
|
2
|
+
export default class JunitBambooFormatter extends Formatter {
|
|
3
|
+
private readonly names;
|
|
4
|
+
private readonly suiteName;
|
|
5
|
+
static readonly documentation: string;
|
|
6
|
+
constructor(options: IFormatterOptions);
|
|
7
|
+
private getTestCases;
|
|
8
|
+
private getTestSteps;
|
|
9
|
+
private getTestStep;
|
|
10
|
+
private getTestCaseResult;
|
|
11
|
+
private durationToSeconds;
|
|
12
|
+
private nameOrDefault;
|
|
13
|
+
private getTestCaseName;
|
|
14
|
+
private formatTestSteps;
|
|
15
|
+
private onTestRunFinished;
|
|
16
|
+
private buildXmlReport;
|
|
17
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const xmlbuilder_1 = __importDefault(require("xmlbuilder"));
|
|
7
|
+
const messages_1 = require("@cucumber/messages");
|
|
8
|
+
const value_checker_1 = require("@cucumber/cucumber/lib/value_checker");
|
|
9
|
+
const pickle_parser_1 = require("@cucumber/cucumber/lib/formatter/helpers/pickle_parser");
|
|
10
|
+
const gherkin_document_parser_1 = require("@cucumber/cucumber/lib/formatter/helpers/gherkin_document_parser");
|
|
11
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
12
|
+
class JunitBambooFormatter extends cucumber_1.Formatter {
|
|
13
|
+
names = {};
|
|
14
|
+
suiteName;
|
|
15
|
+
static documentation = 'Outputs JUnit report';
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(options);
|
|
18
|
+
this.suiteName = (0, value_checker_1.valueOrDefault)(options.parsedArgvOptions.junit?.suiteName, 'cucumber-js');
|
|
19
|
+
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
20
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
21
|
+
this.onTestRunFinished();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
getTestCases() {
|
|
26
|
+
return this.eventDataCollector.getTestCaseAttempts().filter(attempt => !attempt.willBeRetried);
|
|
27
|
+
}
|
|
28
|
+
getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap) {
|
|
29
|
+
return testCaseAttempt.testCase.testSteps.map(testStep => {
|
|
30
|
+
const isBeforeHook = !(0, value_checker_1.doesHaveValue)(testStep.pickleStepId);
|
|
31
|
+
return this.getTestStep({
|
|
32
|
+
isBeforeHook,
|
|
33
|
+
gherkinStepMap,
|
|
34
|
+
pickleStepMap,
|
|
35
|
+
testStep,
|
|
36
|
+
testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],
|
|
37
|
+
testStepResult: testCaseAttempt.stepResults[testStep.id]
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
getTestStep({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult }) {
|
|
42
|
+
const data = {};
|
|
43
|
+
if (testStep.pickleStepId) {
|
|
44
|
+
const pickleStep = pickleStepMap[testStep.pickleStepId];
|
|
45
|
+
data.keyword = (0, pickle_parser_1.getStepKeyword)({ pickleStep, gherkinStepMap });
|
|
46
|
+
data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line;
|
|
47
|
+
data.name = pickleStep.text;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
data.keyword = isBeforeHook ? 'Before' : 'After';
|
|
51
|
+
data.hidden = true;
|
|
52
|
+
}
|
|
53
|
+
data.result = testStepResult;
|
|
54
|
+
data.time = testStepResult.duration ? this.durationToSeconds(testStepResult.duration) : 0;
|
|
55
|
+
data.attachments = testStepAttachments;
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
getTestCaseResult(steps) {
|
|
59
|
+
const { status, message, exception } = (0, messages_1.getWorstTestStepResult)(steps.map(step => step.result));
|
|
60
|
+
return {
|
|
61
|
+
status,
|
|
62
|
+
failure: message || exception
|
|
63
|
+
? {
|
|
64
|
+
type: exception?.type,
|
|
65
|
+
message: exception?.message,
|
|
66
|
+
detail: message
|
|
67
|
+
}
|
|
68
|
+
: undefined
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
durationToSeconds(duration) {
|
|
72
|
+
const NANOS_IN_SECOND = 1_000_000_000;
|
|
73
|
+
return (duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND;
|
|
74
|
+
}
|
|
75
|
+
nameOrDefault(name, fallbackSuffix) {
|
|
76
|
+
if (!name) {
|
|
77
|
+
return `(unnamed ${fallbackSuffix})`;
|
|
78
|
+
}
|
|
79
|
+
return name;
|
|
80
|
+
}
|
|
81
|
+
getTestCaseName(feature, rule, pickle) {
|
|
82
|
+
const featureName = this.nameOrDefault(feature.name, 'feature');
|
|
83
|
+
const pickleName = this.nameOrDefault(pickle.name, 'scenario');
|
|
84
|
+
const testCaseName = rule ? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName : pickleName;
|
|
85
|
+
if (!this.names[featureName]) {
|
|
86
|
+
this.names[featureName] = [];
|
|
87
|
+
}
|
|
88
|
+
let index = 0;
|
|
89
|
+
while (this.names[featureName].includes(index > 0 ? `${testCaseName} [${index}]` : testCaseName)) {
|
|
90
|
+
index++;
|
|
91
|
+
}
|
|
92
|
+
const name = index > 0 ? `${testCaseName} [${index}]` : testCaseName;
|
|
93
|
+
this.names[featureName].push(name);
|
|
94
|
+
return name;
|
|
95
|
+
}
|
|
96
|
+
formatTestSteps(steps) {
|
|
97
|
+
return steps
|
|
98
|
+
.filter(step => !step.hidden)
|
|
99
|
+
.map(step => {
|
|
100
|
+
const statusText = step.result.status.toLowerCase();
|
|
101
|
+
const maxLength = 80 - statusText.length - 3;
|
|
102
|
+
const stepText = `${step.keyword}${step.name}`.padEnd(maxLength, '.').substring(0, maxLength);
|
|
103
|
+
return `${stepText}...${statusText}`;
|
|
104
|
+
})
|
|
105
|
+
.join('\n');
|
|
106
|
+
}
|
|
107
|
+
onTestRunFinished() {
|
|
108
|
+
const testCases = this.getTestCases();
|
|
109
|
+
const tests = testCases.map((testCaseAttempt) => {
|
|
110
|
+
const { gherkinDocument, pickle } = testCaseAttempt;
|
|
111
|
+
const { feature } = gherkinDocument;
|
|
112
|
+
const gherkinExampleRuleMap = (0, gherkin_document_parser_1.getGherkinExampleRuleMap)(gherkinDocument);
|
|
113
|
+
const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]];
|
|
114
|
+
const gherkinStepMap = (0, gherkin_document_parser_1.getGherkinStepMap)(gherkinDocument);
|
|
115
|
+
const pickleStepMap = (0, pickle_parser_1.getPickleStepMap)(pickle);
|
|
116
|
+
const steps = this.getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap);
|
|
117
|
+
const stepDuration = steps.reduce((total, step) => total + (step.time || 0), 0);
|
|
118
|
+
return {
|
|
119
|
+
classname: this.nameOrDefault(feature?.name ?? '', 'feature'),
|
|
120
|
+
name: this.getTestCaseName(feature ?? {}, rule, pickle),
|
|
121
|
+
time: stepDuration,
|
|
122
|
+
result: this.getTestCaseResult(steps),
|
|
123
|
+
systemOutput: this.formatTestSteps(steps),
|
|
124
|
+
steps
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
const passed = tests.filter(item => item.result.status === messages_1.TestStepResultStatus.PASSED).length;
|
|
128
|
+
const skipped = tests.filter(item => item.result.status === messages_1.TestStepResultStatus.SKIPPED ||
|
|
129
|
+
item.result.status === messages_1.TestStepResultStatus.UNDEFINED ||
|
|
130
|
+
item.result.status === messages_1.TestStepResultStatus.PENDING).length;
|
|
131
|
+
const failures = tests.length - passed - skipped;
|
|
132
|
+
const testSuite = {
|
|
133
|
+
name: this.suiteName,
|
|
134
|
+
tests,
|
|
135
|
+
failures,
|
|
136
|
+
skipped,
|
|
137
|
+
time: tests.reduce((total, test) => total + test.time, 0)
|
|
138
|
+
};
|
|
139
|
+
this.log(this.buildXmlReport(testSuite));
|
|
140
|
+
}
|
|
141
|
+
buildXmlReport(testSuite) {
|
|
142
|
+
const xmlReport = xmlbuilder_1.default
|
|
143
|
+
.create('testsuite', { invalidCharReplacement: '' })
|
|
144
|
+
.att('failures', testSuite.failures)
|
|
145
|
+
.att('skipped', testSuite.skipped)
|
|
146
|
+
.att('name', testSuite.name)
|
|
147
|
+
.att('time', testSuite.time)
|
|
148
|
+
.att('tests', testSuite.tests.length);
|
|
149
|
+
testSuite.tests.forEach(test => {
|
|
150
|
+
const xmlTestCase = xmlReport.ele('testcase', {
|
|
151
|
+
classname: test.classname,
|
|
152
|
+
name: test.name,
|
|
153
|
+
time: test.time
|
|
154
|
+
});
|
|
155
|
+
if (test.result.status === messages_1.TestStepResultStatus.SKIPPED ||
|
|
156
|
+
test.result.status === messages_1.TestStepResultStatus.PENDING ||
|
|
157
|
+
test.result.status === messages_1.TestStepResultStatus.UNDEFINED) {
|
|
158
|
+
xmlTestCase.ele('skipped');
|
|
159
|
+
}
|
|
160
|
+
else if (test.result.status !== messages_1.TestStepResultStatus.PASSED) {
|
|
161
|
+
const xmlFailure = xmlTestCase.ele('failure', {
|
|
162
|
+
type: test.result.failure?.type,
|
|
163
|
+
message: test.result.failure?.message
|
|
164
|
+
});
|
|
165
|
+
if (test.result?.failure) {
|
|
166
|
+
xmlFailure.cdata(test.result.failure.detail);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
xmlTestCase.ele('system-out', {}).cdata(test.systemOutput);
|
|
170
|
+
});
|
|
171
|
+
return xmlReport.end({ pretty: true });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.default = JunitBambooFormatter;
|
|
175
|
+
//# sourceMappingURL=junit-bamboo-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"junit-bamboo-formatter.js","sourceRoot":"","sources":["../../src/formatter/junit-bamboo-formatter.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AAEpC,iDAS4B;AAE5B,wEAAqF;AACrF,0FAA0G;AAC1G,8GAG0E;AAC1E,iDAAkE;AAiDlE,MAAqB,oBAAqB,SAAQ,oBAAS;IACzC,KAAK,GAA6B,EAAE,CAAC;IACrC,SAAS,CAAS;IAC5B,MAAM,CAAU,aAAa,GAAW,sBAAsB,CAAC;IAEtE,YAAY,OAA0B;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,IAAA,8BAAc,EAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;QAC3F,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACvE,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC1B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,YAAY;QACnB,OAAO,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAChG,CAAC;IAEO,YAAY,CACnB,eAAiC,EACjC,cAA6C,EAC7C,aAAk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["import xmlbuilder from 'xmlbuilder';\r\nimport * as messages from '@cucumber/messages';\r\nimport {\r\n\tAttachment,\r\n\tDuration,\r\n\tFeature,\r\n\tgetWorstTestStepResult,\r\n\tPickle,\r\n\tRule,\r\n\tTestStepResult,\r\n\tTestStepResultStatus\r\n} from '@cucumber/messages';\r\nimport { ITestCaseAttempt } from '@cucumber/cucumber/lib/formatter/helpers/event_data_collector';\r\nimport { doesHaveValue, valueOrDefault } from '@cucumber/cucumber/lib/value_checker';\r\nimport { getPickleStepMap, getStepKeyword } from '@cucumber/cucumber/lib/formatter/helpers/pickle_parser';\r\nimport {\r\n\tgetGherkinExampleRuleMap,\r\n\tgetGherkinStepMap\r\n} from '@cucumber/cucumber/lib/formatter/helpers/gherkin_document_parser';\r\nimport { Formatter, IFormatterOptions } from '@cucumber/cucumber';\r\n\r\ninterface IJUnitTestSuite {\r\n\tname: string;\r\n\tfailures: number;\r\n\tskipped: number;\r\n\ttime: number;\r\n\ttests: IJUnitTestCase[];\r\n}\r\n\r\ninterface IJUnitTestCase {\r\n\tclassname: string;\r\n\tname: string;\r\n\ttime: number;\r\n\tresult: IJUnitTestCaseResult;\r\n\tsystemOutput: string;\r\n\tsteps: IJUnitTestStep[];\r\n}\r\n\r\ninterface IJUnitTestCaseFailure {\r\n\ttype: string;\r\n\tmessage?: string;\r\n\tdetail: string;\r\n}\r\n\r\ninterface IJUnitTestCaseResult {\r\n\tstatus: TestStepResultStatus;\r\n\tfailure?: IJUnitTestCaseFailure;\r\n}\r\n\r\ninterface IJUnitTestStep {\r\n\tattachments: Attachment[];\r\n\thidden: boolean;\r\n\tkeyword: string;\r\n\tline: number;\r\n\tname?: string;\r\n\tresult: TestStepResult;\r\n\ttime: number;\r\n}\r\n\r\ninterface IBuildJUnitTestStepOptions {\r\n\tisBeforeHook: boolean;\r\n\tgherkinStepMap: Record<string, messages.Step>;\r\n\tpickleStepMap: Record<string, messages.PickleStep>;\r\n\ttestStep: messages.TestStep;\r\n\ttestStepAttachments: messages.Attachment[];\r\n\ttestStepResult: messages.TestStepResult;\r\n}\r\n\r\nexport default class JunitBambooFormatter extends Formatter {\r\n\tprivate readonly names: Record<string, string[]> = {};\r\n\tprivate readonly suiteName: string;\r\n\tpublic static readonly documentation: string = 'Outputs JUnit report';\r\n\r\n\tconstructor(options: IFormatterOptions) {\r\n\t\tsuper(options);\r\n\t\tthis.suiteName = valueOrDefault(options.parsedArgvOptions.junit?.suiteName, 'cucumber-js');\r\n\t\toptions.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\r\n\t\t\tif (doesHaveValue(envelope.testRunFinished)) {\r\n\t\t\t\tthis.onTestRunFinished();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tprivate getTestCases() {\r\n\t\treturn this.eventDataCollector.getTestCaseAttempts().filter(attempt => !attempt.willBeRetried);\r\n\t}\r\n\r\n\tprivate getTestSteps(\r\n\t\ttestCaseAttempt: ITestCaseAttempt,\r\n\t\tgherkinStepMap: Record<string, messages.Step>,\r\n\t\tpickleStepMap: Record<string, messages.PickleStep>\r\n\t) {\r\n\t\treturn testCaseAttempt.testCase.testSteps.map(testStep => {\r\n\t\t\tconst isBeforeHook = !doesHaveValue(testStep.pickleStepId);\r\n\t\t\treturn this.getTestStep({\r\n\t\t\t\tisBeforeHook,\r\n\t\t\t\tgherkinStepMap,\r\n\t\t\t\tpickleStepMap,\r\n\t\t\t\ttestStep,\r\n\t\t\t\ttestStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\r\n\t\t\t\ttestStepResult: testCaseAttempt.stepResults[testStep.id]\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\tprivate getTestStep({\r\n\t\tisBeforeHook,\r\n\t\tgherkinStepMap,\r\n\t\tpickleStepMap,\r\n\t\ttestStep,\r\n\t\ttestStepAttachments,\r\n\t\ttestStepResult\r\n\t}: IBuildJUnitTestStepOptions): IJUnitTestStep {\r\n\t\tconst data: Partial<IJUnitTestStep> = {};\r\n\t\tif (testStep.pickleStepId) {\r\n\t\t\tconst pickleStep = pickleStepMap[testStep.pickleStepId];\r\n\t\t\tdata.keyword = getStepKeyword({ pickleStep, gherkinStepMap });\r\n\t\t\tdata.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line;\r\n\t\t\tdata.name = pickleStep.text;\r\n\t\t} else {\r\n\t\t\tdata.keyword = isBeforeHook ? 'Before' : 'After';\r\n\t\t\tdata.hidden = true;\r\n\t\t}\r\n\t\tdata.result = testStepResult;\r\n\t\tdata.time = testStepResult.duration ? this.durationToSeconds(testStepResult.duration) : 0;\r\n\t\tdata.attachments = testStepAttachments;\r\n\t\treturn data as IJUnitTestStep;\r\n\t}\r\n\r\n\tprivate getTestCaseResult(steps: IJUnitTestStep[]): IJUnitTestCaseResult {\r\n\t\tconst { status, message, exception } = getWorstTestStepResult(steps.map(step => step.result));\r\n\t\treturn {\r\n\t\t\tstatus,\r\n\t\t\tfailure:\r\n\t\t\t\tmessage || exception\r\n\t\t\t\t\t? ({\r\n\t\t\t\t\t\t\ttype: exception?.type,\r\n\t\t\t\t\t\t\tmessage: exception?.message,\r\n\t\t\t\t\t\t\tdetail: message\r\n\t\t\t\t\t\t} as IJUnitTestCaseFailure)\r\n\t\t\t\t\t: undefined\r\n\t\t};\r\n\t}\r\n\r\n\tprivate durationToSeconds(duration: Duration): number {\r\n\t\tconst NANOS_IN_SECOND = 1_000_000_000;\r\n\t\treturn (duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND;\r\n\t}\r\n\r\n\tprivate nameOrDefault(name: string, fallbackSuffix: string): string {\r\n\t\tif (!name) {\r\n\t\t\treturn `(unnamed ${fallbackSuffix})`;\r\n\t\t}\r\n\t\treturn name;\r\n\t}\r\n\r\n\tprivate getTestCaseName(feature: Feature, rule: Rule | undefined, pickle: Pickle) {\r\n\t\tconst featureName = this.nameOrDefault(feature.name, 'feature');\r\n\t\tconst pickleName = this.nameOrDefault(pickle.name, 'scenario');\r\n\t\tconst testCaseName = rule ? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName : pickleName;\r\n\t\tif (!this.names[featureName]) {\r\n\t\t\tthis.names[featureName] = [];\r\n\t\t}\r\n\t\tlet index = 0;\r\n\t\twhile (this.names[featureName].includes(index > 0 ? `${testCaseName} [${index}]` : testCaseName)) {\r\n\t\t\tindex++;\r\n\t\t}\r\n\t\tconst name = index > 0 ? `${testCaseName} [${index}]` : testCaseName;\r\n\t\tthis.names[featureName].push(name);\r\n\t\treturn name;\r\n\t}\r\n\r\n\tprivate formatTestSteps(steps: IJUnitTestStep[]): string {\r\n\t\treturn steps\r\n\t\t\t.filter(step => !step.hidden)\r\n\t\t\t.map(step => {\r\n\t\t\t\tconst statusText = step.result.status.toLowerCase();\r\n\t\t\t\tconst maxLength = 80 - statusText.length - 3;\r\n\t\t\t\tconst stepText = `${step.keyword}${step.name}`.padEnd(maxLength, '.').substring(0, maxLength);\r\n\t\t\t\treturn `${stepText}...${statusText}`;\r\n\t\t\t})\r\n\t\t\t.join('\\n');\r\n\t}\r\n\r\n\tprivate onTestRunFinished(): void {\r\n\t\tconst testCases = this.getTestCases();\r\n\r\n\t\tconst tests = testCases.map<IJUnitTestCase>((testCaseAttempt: ITestCaseAttempt) => {\r\n\t\t\tconst { gherkinDocument, pickle } = testCaseAttempt;\r\n\t\t\tconst { feature } = gherkinDocument;\r\n\t\t\tconst gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument);\r\n\t\t\tconst rule = gherkinExampleRuleMap[pickle.astNodeIds[0]];\r\n\t\t\tconst gherkinStepMap = getGherkinStepMap(gherkinDocument);\r\n\t\t\tconst pickleStepMap = getPickleStepMap(pickle);\r\n\r\n\t\t\tconst steps = this.getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap);\r\n\t\t\tconst stepDuration = steps.reduce((total, step) => total + (step.time || 0), 0);\r\n\r\n\t\t\treturn {\r\n\t\t\t\tclassname: this.nameOrDefault(feature?.name ?? '', 'feature'),\r\n\t\t\t\tname: this.getTestCaseName(feature ?? ({} as Feature), rule, pickle),\r\n\t\t\t\ttime: stepDuration,\r\n\t\t\t\tresult: this.getTestCaseResult(steps),\r\n\t\t\t\tsystemOutput: this.formatTestSteps(steps),\r\n\t\t\t\tsteps\r\n\t\t\t};\r\n\t\t});\r\n\r\n\t\tconst passed = tests.filter(item => item.result.status === TestStepResultStatus.PASSED).length;\r\n\t\tconst skipped = tests.filter(\r\n\t\t\titem =>\r\n\t\t\t\titem.result.status === TestStepResultStatus.SKIPPED ||\r\n\t\t\t\titem.result.status === TestStepResultStatus.UNDEFINED ||\r\n\t\t\t\titem.result.status === TestStepResultStatus.PENDING\r\n\t\t).length;\r\n\t\tconst failures = tests.length - passed - skipped;\r\n\r\n\t\tconst testSuite: IJUnitTestSuite = {\r\n\t\t\tname: this.suiteName,\r\n\t\t\ttests,\r\n\t\t\tfailures,\r\n\t\t\tskipped,\r\n\t\t\ttime: tests.reduce((total, test) => total + test.time, 0)\r\n\t\t};\r\n\r\n\t\tthis.log(this.buildXmlReport(testSuite));\r\n\t}\r\n\r\n\tprivate buildXmlReport(testSuite: IJUnitTestSuite): string {\r\n\t\tconst xmlReport = xmlbuilder\r\n\t\t\t.create('testsuite', { invalidCharReplacement: '' })\r\n\t\t\t.att('failures', testSuite.failures)\r\n\t\t\t.att('skipped', testSuite.skipped)\r\n\t\t\t.att('name', testSuite.name)\r\n\t\t\t.att('time', testSuite.time)\r\n\t\t\t.att('tests', testSuite.tests.length);\r\n\t\ttestSuite.tests.forEach(test => {\r\n\t\t\tconst xmlTestCase = xmlReport.ele('testcase', {\r\n\t\t\t\tclassname: test.classname,\r\n\t\t\t\tname: test.name,\r\n\t\t\t\ttime: test.time\r\n\t\t\t});\r\n\t\t\tif (\r\n\t\t\t\ttest.result.status === TestStepResultStatus.SKIPPED ||\r\n\t\t\t\ttest.result.status === TestStepResultStatus.PENDING ||\r\n\t\t\t\ttest.result.status === TestStepResultStatus.UNDEFINED\r\n\t\t\t) {\r\n\t\t\t\txmlTestCase.ele('skipped');\r\n\t\t\t} else if (test.result.status !== TestStepResultStatus.PASSED) {\r\n\t\t\t\tconst xmlFailure = xmlTestCase.ele('failure', {\r\n\t\t\t\t\ttype: test.result.failure?.type,\r\n\t\t\t\t\tmessage: test.result.failure?.message\r\n\t\t\t\t});\r\n\t\t\t\tif (test.result?.failure) {\r\n\t\t\t\t\txmlFailure.cdata(test.result.failure.detail);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\txmlTestCase.ele('system-out', {}).cdata(test.systemOutput);\r\n\t\t});\r\n\r\n\t\treturn xmlReport.end({ pretty: true });\r\n\t}\r\n}\r\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ISnippetSnytax, ISnippetSyntaxBuildOptions, SnippetInterface } from '@cucumber/cucumber/lib/formatter/step_definition_snippet_builder/snippet_syntax';
|
|
2
|
+
/**
|
|
3
|
+
* Generate snippets for tsflow.
|
|
4
|
+
*/
|
|
5
|
+
export default class TsflowSnippetSyntax implements ISnippetSnytax {
|
|
6
|
+
private readonly snippetInterface;
|
|
7
|
+
constructor(snippetInterface: SnippetInterface);
|
|
8
|
+
build({ comment, generatedExpressions, functionName, stepParameterNames }: ISnippetSyntaxBuildOptions): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const snippet_syntax_1 = require("@cucumber/cucumber/lib/formatter/step_definition_snippet_builder/snippet_syntax");
|
|
4
|
+
const CALLBACK_NAME = 'callback';
|
|
5
|
+
const toCamelCase = (str) => {
|
|
6
|
+
return str
|
|
7
|
+
.replace(/\s(.)/g, function ($1) {
|
|
8
|
+
return $1.toUpperCase();
|
|
9
|
+
})
|
|
10
|
+
.replace(/\s/g, '')
|
|
11
|
+
.replace(/[^\w]/g, '')
|
|
12
|
+
.replace(/^(.)/, function ($1) {
|
|
13
|
+
return $1.toLowerCase();
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* format cucumber expression parameters for typescript
|
|
18
|
+
* @param parameters
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
const formatParameters = (parameters) => {
|
|
22
|
+
const params = parameters.map(param => {
|
|
23
|
+
return `${param}: ${matchType(param)}`;
|
|
24
|
+
});
|
|
25
|
+
return params.join(', ');
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* match the parameter name passed in with a typescript
|
|
29
|
+
* primitive type (string, number or boolean)
|
|
30
|
+
* @param paramName
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
const matchType = (paramName) => {
|
|
34
|
+
const numberTypes = ['int', 'float', 'bigdecimal', 'double', 'biginteger', 'byte', 'short', 'long'];
|
|
35
|
+
const stringTypes = ['string', 'word'];
|
|
36
|
+
if (stringTypes.find(x => paramName.indexOf(x) >= 0)) {
|
|
37
|
+
return 'string';
|
|
38
|
+
}
|
|
39
|
+
if (numberTypes.find(x => paramName.indexOf(x) >= 0)) {
|
|
40
|
+
return 'number';
|
|
41
|
+
}
|
|
42
|
+
if (paramName.indexOf('boolean') >= 0) {
|
|
43
|
+
return 'boolean';
|
|
44
|
+
}
|
|
45
|
+
return 'any';
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Generate snippets for tsflow.
|
|
49
|
+
*/
|
|
50
|
+
class TsflowSnippetSyntax {
|
|
51
|
+
snippetInterface;
|
|
52
|
+
constructor(snippetInterface) {
|
|
53
|
+
this.snippetInterface = snippetInterface;
|
|
54
|
+
}
|
|
55
|
+
build({ comment, generatedExpressions, functionName, stepParameterNames }) {
|
|
56
|
+
let functionKeyword = '';
|
|
57
|
+
if (this.snippetInterface === snippet_syntax_1.SnippetInterface.AsyncAwait) {
|
|
58
|
+
functionKeyword = 'async ';
|
|
59
|
+
}
|
|
60
|
+
let implementation;
|
|
61
|
+
if (this.snippetInterface === snippet_syntax_1.SnippetInterface.Callback) {
|
|
62
|
+
implementation = `${CALLBACK_NAME}(null, 'pending');`;
|
|
63
|
+
}
|
|
64
|
+
else if (this.snippetInterface === snippet_syntax_1.SnippetInterface.Promise) {
|
|
65
|
+
implementation = "return Promise.resolve('pending');";
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
implementation = "return 'pending';";
|
|
69
|
+
}
|
|
70
|
+
// we only care about the first expression. TypeScript has a
|
|
71
|
+
// small number of primitive types
|
|
72
|
+
const generatedExpression = generatedExpressions[0];
|
|
73
|
+
const allParameterNames = generatedExpression.parameterNames.concat(stepParameterNames);
|
|
74
|
+
if (this.snippetInterface === snippet_syntax_1.SnippetInterface.Callback) {
|
|
75
|
+
allParameterNames.push(CALLBACK_NAME);
|
|
76
|
+
}
|
|
77
|
+
const pattern = generatedExpression.source.replace(/'/g, "\\'");
|
|
78
|
+
const methodName = toCamelCase(pattern);
|
|
79
|
+
const parametersStr = allParameterNames.length > 0 ? formatParameters(allParameterNames) : '';
|
|
80
|
+
const definitionChoices = `@${functionName.toLowerCase()}('${pattern}')\n` + `${functionKeyword}${methodName}(${parametersStr}): any {\n`;
|
|
81
|
+
return `${definitionChoices} //${comment}\n ${implementation}\n}`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.default = TsflowSnippetSyntax;
|
|
85
|
+
//# sourceMappingURL=tsflow-snippet-syntax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsflow-snippet-syntax.js","sourceRoot":"","sources":["../../../src/formatter/step-definition-snippit-syntax/tsflow-snippet-syntax.ts"],"names":[],"mappings":";;AAAA,oHAIyF;AAEzF,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE;IACnC,OAAO,GAAG;SACR,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE;QAC9B,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC;IACzB,CAAC,CAAC;SACD,O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,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9F,MAAM,iBAAiB,GACtB,IAAI,YAAY,CAAC,WAAW,EAAE,KAAK,OAAO,MAAM,GAAG,GAAG,eAAe,GAAG,UAAU,IAAI,aAAa,YAAY,CAAC;QAEjH,OAAO,GAAG,iBAAiB,OAAO,OAAO,OAAO,cAAc,KAAK,CAAC;IACrE,CAAC;CACD;AAnCD,sCAmCC","sourcesContent":["import {\r\n\tISnippetSnytax,\r\n\tISnippetSyntaxBuildOptions,\r\n\tSnippetInterface\r\n} from '@cucumber/cucumber/lib/formatter/step_definition_snippet_builder/snippet_syntax';\r\n\r\nconst CALLBACK_NAME = 'callback';\r\n\r\nconst toCamelCase = (str: string) => {\r\n\treturn str\r\n\t\t.replace(/\\s(.)/g, function ($1) {\r\n\t\t\treturn $1.toUpperCase();\r\n\t\t})\r\n\t\t.replace(/\\s/g, '')\r\n\t\t.replace(/[^\\w]/g, '')\r\n\t\t.replace(/^(.)/, function ($1) {\r\n\t\t\treturn $1.toLowerCase();\r\n\t\t});\r\n};\r\n\r\n/**\r\n * format cucumber expression parameters for typescript\r\n * @param parameters\r\n * @returns\r\n */\r\nconst formatParameters = (parameters: string[]): string => {\r\n\tconst params = parameters.map(param => {\r\n\t\treturn `${param}: ${matchType(param)}`;\r\n\t});\r\n\treturn params.join(', ');\r\n};\r\n\r\n/**\r\n * match the parameter name passed in with a typescript\r\n * primitive type (string, number or boolean)\r\n * @param paramName\r\n * @returns\r\n */\r\nconst matchType = (paramName: string): string => {\r\n\tconst numberTypes = ['int', 'float', 'bigdecimal', 'double', 'biginteger', 'byte', 'short', 'long'];\r\n\tconst stringTypes = ['string', 'word'];\r\n\r\n\tif (stringTypes.find(x => paramName.indexOf(x) >= 0)) {\r\n\t\treturn 'string';\r\n\t}\r\n\tif (numberTypes.find(x => paramName.indexOf(x) >= 0)) {\r\n\t\treturn 'number';\r\n\t}\r\n\tif (paramName.indexOf('boolean') >= 0) {\r\n\t\treturn 'boolean';\r\n\t}\r\n\treturn 'any';\r\n};\r\n\r\n/**\r\n * Generate snippets for tsflow.\r\n */\r\nexport default class TsflowSnippetSyntax implements ISnippetSnytax {\r\n\tprivate readonly snippetInterface: SnippetInterface;\r\n\r\n\tconstructor(snippetInterface: SnippetInterface) {\r\n\t\tthis.snippetInterface = snippetInterface;\r\n\t}\r\n\r\n\tbuild({ comment, generatedExpressions, functionName, stepParameterNames }: ISnippetSyntaxBuildOptions): string {\r\n\t\tlet functionKeyword = '';\r\n\t\tif (this.snippetInterface === SnippetInterface.AsyncAwait) {\r\n\t\t\tfunctionKeyword = 'async ';\r\n\t\t}\r\n\t\tlet implementation: string;\r\n\t\tif (this.snippetInterface === SnippetInterface.Callback) {\r\n\t\t\timplementation = `${CALLBACK_NAME}(null, 'pending');`;\r\n\t\t} else if (this.snippetInterface === SnippetInterface.Promise) {\r\n\t\t\timplementation = \"return Promise.resolve('pending');\";\r\n\t\t} else {\r\n\t\t\timplementation = \"return 'pending';\";\r\n\t\t}\r\n\t\t// we only care about the first expression. TypeScript has a\r\n\t\t// small number of primitive types\r\n\t\tconst generatedExpression = generatedExpressions[0];\r\n\t\tconst allParameterNames = generatedExpression.parameterNames.concat(stepParameterNames);\r\n\t\tif (this.snippetInterface === SnippetInterface.Callback) {\r\n\t\t\tallParameterNames.push(CALLBACK_NAME);\r\n\t\t}\r\n\t\tconst pattern = generatedExpression.source.replace(/'/g, \"\\\\'\");\r\n\t\tconst methodName = toCamelCase(pattern);\r\n\t\tconst parametersStr = allParameterNames.length > 0 ? formatParameters(allParameterNames) : '';\r\n\t\tconst definitionChoices =\r\n\t\t\t`@${functionName.toLowerCase()}('${pattern}')\\n` + `${functionKeyword}${methodName}(${parametersStr}): any {\\n`;\r\n\r\n\t\treturn `${definitionChoices} //${comment}\\n ${implementation}\\n}`;\r\n\t}\r\n}\r\n"]}
|