@uuv/playwright 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { Formatter } from "cucumber-json-report-formatter";
2
+ export declare class UuvCustomFormatter extends Formatter {
3
+ constructor();
4
+ parseCucumberJson(sourceFile: any, outputFile: any): Promise<void>;
5
+ private buildAndAddScenario;
6
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UuvCustomFormatter = void 0;
4
+ const cucumber_json_report_formatter_1 = require("cucumber-json-report-formatter");
5
+ // FIXME remove this class when the PR https://github.com/vrymar/cucumber-json-report-formatter/pull/20 will be merged
6
+ class UuvCustomFormatter extends cucumber_json_report_formatter_1.Formatter {
7
+ constructor() {
8
+ super();
9
+ }
10
+ async parseCucumberJson(sourceFile, outputFile) {
11
+ console.info(`Start formatting file '${sourceFile}' into '${outputFile}'`);
12
+ const report = await this.helper.readFileIntoJson(sourceFile);
13
+ const gherkinDocumentJson = this.helper.getJsonFromArray(report, "gherkinDocument");
14
+ const cucumberReport = [];
15
+ gherkinDocumentJson.forEach(gherkinJson => {
16
+ let gherkinDocument;
17
+ try {
18
+ gherkinDocument = JSON.parse(gherkinJson).gherkinDocument;
19
+ }
20
+ catch (err) {
21
+ console.error("Error parsing JSON string.", err);
22
+ }
23
+ const feature = gherkinDocument.feature;
24
+ const featureChildren = feature.children;
25
+ const scenariosJson = [];
26
+ const background = {};
27
+ featureChildren.forEach(featureChild => {
28
+ if (featureChild.rule) {
29
+ featureChild.rule.steps = [];
30
+ featureChild.rule.children.forEach(ruleChildren => {
31
+ this.buildAndAddScenario(ruleChildren, report, background, feature, scenariosJson, featureChild.rule);
32
+ });
33
+ }
34
+ else {
35
+ this.buildAndAddScenario(featureChild, report, background, feature, scenariosJson, undefined);
36
+ }
37
+ });
38
+ const rootJson = {
39
+ comments: this.getComments(gherkinDocument.comments),
40
+ description: gherkinDocument.feature.description,
41
+ elements: scenariosJson,
42
+ id: feature.name,
43
+ keyword: feature.keyword,
44
+ line: feature.location.line,
45
+ name: feature.name,
46
+ uri: gherkinDocument.uri,
47
+ tags: this.getTags(gherkinDocument.feature.tags)
48
+ };
49
+ cucumberReport.push(rootJson);
50
+ });
51
+ await this.validateReportSchema(report);
52
+ const reportString = JSON.stringify(cucumberReport);
53
+ console.info(`Finished formatting file '${sourceFile}'`);
54
+ this.helper.writeFile(outputFile, reportString);
55
+ }
56
+ buildAndAddScenario(child, report, background, feature, scenariosJson, rule) {
57
+ let steps = [];
58
+ let stepJson = {};
59
+ // Background
60
+ if (child.scenario === undefined) {
61
+ child.background.steps.forEach(step => {
62
+ stepJson = this.createStepJson(step, report, 0);
63
+ steps.push(stepJson);
64
+ });
65
+ background = this.createScenarioJson(feature, child.background, steps, "background");
66
+ // eslint-disable-next-line brace-style
67
+ }
68
+ // Normal Scenario
69
+ else if (!child.scenario.keyword.includes("Outline")) {
70
+ child.scenario.steps.forEach(step => {
71
+ stepJson = this.createStepJson(step, report, 0);
72
+ steps.push(stepJson);
73
+ });
74
+ const scenario = this.createScenarioJson(feature, child.scenario, steps, "scenario");
75
+ if (rule) {
76
+ scenario.id = `${feature.name};${rule.name};${scenario.name}`;
77
+ }
78
+ if (Object.keys(background).length !== 0 && background !== undefined) {
79
+ scenariosJson.push(background);
80
+ }
81
+ scenariosJson.push(scenario);
82
+ } /* Scenario Outline */
83
+ else if (child.scenario.examples[0].tableBody !== undefined) {
84
+ const numberOfExecutions = child.scenario.examples[0].tableBody.length;
85
+ const numberOfStepsEachExecution = child.scenario.steps.length;
86
+ let scenarioIndex = 0;
87
+ while (scenarioIndex < numberOfExecutions) {
88
+ let currentStep = 0;
89
+ steps = [];
90
+ while (currentStep < numberOfStepsEachExecution) {
91
+ stepJson = this.createStepJson(child.scenario.steps[currentStep], report, scenarioIndex);
92
+ currentStep++;
93
+ steps.push(stepJson);
94
+ }
95
+ const scenario = this.createScenarioJson(feature, child.scenario, steps, "scenario", scenarioIndex);
96
+ if (rule) {
97
+ scenario.id = `${feature.name};${rule.name};${scenario.name}`;
98
+ }
99
+ if (Object.keys(background).length !== 0 && background !== undefined) {
100
+ scenariosJson.push(background);
101
+ }
102
+ scenariosJson.push(scenario);
103
+ scenarioIndex++;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ exports.UuvCustomFormatter = UuvCustomFormatter;
@@ -10,10 +10,10 @@ const messages_1 = require("@cucumber/messages");
10
10
  const fs_1 = __importDefault(require("fs"));
11
11
  const runner_playwright_1 = require("../lib/runner-playwright");
12
12
  const multiple_cucumber_html_reporter_1 = __importDefault(require("multiple-cucumber-html-reporter"));
13
- const cucumber_json_report_formatter_1 = require("cucumber-json-report-formatter");
14
13
  const nanoid_1 = require("nanoid");
15
14
  const chalk_1 = __importDefault(require("chalk"));
16
15
  const chalk_table_1 = __importDefault(require("chalk-table"));
16
+ const uuv_custom_formatter_1 = require("./uuv-custom-formatter");
17
17
  const NANOS_IN_SECOND = 1000000000;
18
18
  const NANOS_IN_MILLISSECOND = 1000000;
19
19
  var GeneratedReportType;
@@ -364,7 +364,7 @@ class UuvPlaywrightReporterHelper {
364
364
  return [...new Set(suite.allTests().map(testCase => testCase.location?.file))];
365
365
  }
366
366
  async formatCucumberMessageFile(inputMessageFile, outputFormattedFileJson) {
367
- const formatter = new cucumber_json_report_formatter_1.Formatter();
367
+ const formatter = new uuv_custom_formatter_1.UuvCustomFormatter();
368
368
  await formatter.parseCucumberJson(inputMessageFile, outputFormattedFileJson);
369
369
  }
370
370
  generateHtmlReportFromJson(reportDirHtml, reportDirJson) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uuv/playwright",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "type": "commonjs",
5
5
  "author": "Louis Fredice NJAKO MOLOM (https://github.com/luifr10) & Stanley SERVICAL (https://github.com/stanlee974)",
6
6
  "description": "A solution to run E2E tests written in cucumber(BDD) with playwright.",
@@ -46,7 +46,7 @@
46
46
  "dependencies": {
47
47
  "@cucumber/cucumber": "9.3.0",
48
48
  "@playwright/test": "1.33.0",
49
- "@uuv/runner-commons": "1.6.1",
49
+ "@uuv/runner-commons": "1.6.2",
50
50
  "axe-core": "4.7.2",
51
51
  "axe-playwright": "1.2.3",
52
52
  "chalk": "4.1.2",