allure-cucumberjs 3.0.0-beta.1 → 3.0.0-beta.10

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/dist/cjs/index.js CHANGED
@@ -12,21 +12,35 @@ Object.defineProperty(exports, "AllureCucumberTestRuntime", {
12
12
  Object.defineProperty(exports, "AllureCucumberWorld", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
- return _world.AllureCucumberWorld;
15
+ return _legacy.AllureCucumberWorld;
16
16
  }
17
17
  });
18
18
  var _cucumber = require("@cucumber/cucumber");
19
+ var _reporter = require("allure-js-commons/sdk/reporter");
19
20
  var _runtime = require("allure-js-commons/sdk/runtime");
21
+ var _legacy = require("./legacy.js");
20
22
  var _runtime2 = require("./runtime.js");
21
- var _world = require("./world.js");
22
- (0, _cucumber.Before)(function () {
23
- // TODO: we can implement testplan logic there
24
- (0, _runtime.setGlobalTestRuntime)(
25
- // @ts-ignore
26
- new _runtime2.AllureCucumberTestRuntime({
27
- attach: this.attach,
28
- log: this.log,
29
- parameters: this.parameters
30
- }));
23
+ (0, _cucumber.BeforeAll)(() => {
24
+ (0, _runtime.setGlobalTestRuntime)(new _runtime2.AllureCucumberTestRuntime());
25
+ });
26
+ (0, _cucumber.Before)({
27
+ name: "ALLURE_FIXTURE_IGNORE"
28
+ }, scenario => {
29
+ var testPlan = (0, _reporter.parseTestPlan)();
30
+ if (!testPlan) {
31
+ return;
32
+ }
33
+ var pickle = scenario.pickle;
34
+ var fullName = "".concat(pickle.uri, "#").concat(pickle.name);
35
+ var tags = pickle.tags.map(tag => tag.name);
36
+ if (!(0, _reporter.includedInTestPlan)(testPlan, {
37
+ fullName,
38
+ tags
39
+ })) {
40
+ // we can't use regular message or Allure facade since we need label to be added
41
+ // to test, not fixture
42
+ _cucumber.world.attach(Buffer.from("allure-skip"), "application/vnd.allure.skipcucumber+json");
43
+ return "skipped";
44
+ }
31
45
  });
32
46
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_cucumber","require","_runtime","_runtime2","_world","Before","setGlobalTestRuntime","AllureCucumberTestRuntime","attach","log","parameters"],"sources":["../../src/index.ts"],"sourcesContent":["import { Before } from \"@cucumber/cucumber\";\nimport { setGlobalTestRuntime } from \"allure-js-commons/sdk/runtime\";\nimport { AllureCucumberTestRuntime } from \"./runtime.js\";\nimport { AllureCucumberWorld } from \"./world.js\";\n\nBefore(function () {\n // TODO: we can implement testplan logic there\n setGlobalTestRuntime(\n // @ts-ignore\n new AllureCucumberTestRuntime({\n attach: this.attach,\n log: this.log,\n parameters: this.parameters,\n }),\n );\n});\n\nexport { AllureCucumberTestRuntime, AllureCucumberWorld };\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAM,EAAC,YAAY;EACjB;EACA,IAAAC,6BAAoB;EAClB;EACA,IAAIC,mCAAyB,CAAC;IAC5BC,MAAM,EAAE,IAAI,CAACA,MAAM;IACnBC,GAAG,EAAE,IAAI,CAACA,GAAG;IACbC,UAAU,EAAE,IAAI,CAACA;EACnB,CAAC,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_cucumber","require","_reporter","_runtime","_legacy","_runtime2","BeforeAll","setGlobalTestRuntime","AllureCucumberTestRuntime","Before","name","scenario","testPlan","parseTestPlan","pickle","fullName","concat","uri","tags","map","tag","includedInTestPlan","world","attach","Buffer","from"],"sources":["../../src/index.ts"],"sourcesContent":["import { Before, BeforeAll, world } from \"@cucumber/cucumber\";\nimport { includedInTestPlan } from \"allure-js-commons/sdk/reporter\";\nimport { parseTestPlan } from \"allure-js-commons/sdk/reporter\";\nimport { setGlobalTestRuntime } from \"allure-js-commons/sdk/runtime\";\nimport { AllureCucumberWorld } from \"./legacy.js\";\nimport { AllureCucumberTestRuntime } from \"./runtime.js\";\n\nBeforeAll(() => {\n setGlobalTestRuntime(new AllureCucumberTestRuntime());\n});\n\nBefore({ name: \"ALLURE_FIXTURE_IGNORE\" }, (scenario) => {\n const testPlan = parseTestPlan();\n if (!testPlan) {\n return;\n }\n const pickle = scenario.pickle;\n const fullName = `${pickle.uri}#${pickle.name}`;\n const tags = pickle.tags.map((tag) => tag.name);\n\n if (!includedInTestPlan(testPlan, { fullName, tags })) {\n // we can't use regular message or Allure facade since we need label to be added\n // to test, not fixture\n world.attach(Buffer.from(\"allure-skip\"), \"application/vnd.allure.skipcucumber+json\");\n return \"skipped\";\n }\n});\n\nexport { AllureCucumberTestRuntime, AllureCucumberWorld };\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,mBAAS,EAAC,MAAM;EACd,IAAAC,6BAAoB,EAAC,IAAIC,mCAAyB,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,IAAAC,gBAAM,EAAC;EAAEC,IAAI,EAAE;AAAwB,CAAC,EAAGC,QAAQ,IAAK;EACtD,IAAMC,QAAQ,GAAG,IAAAC,uBAAa,EAAC,CAAC;EAChC,IAAI,CAACD,QAAQ,EAAE;IACb;EACF;EACA,IAAME,MAAM,GAAGH,QAAQ,CAACG,MAAM;EAC9B,IAAMC,QAAQ,MAAAC,MAAA,CAAMF,MAAM,CAACG,GAAG,OAAAD,MAAA,CAAIF,MAAM,CAACJ,IAAI,CAAE;EAC/C,IAAMQ,IAAI,GAAGJ,MAAM,CAACI,IAAI,CAACC,GAAG,CAAEC,GAAG,IAAKA,GAAG,CAACV,IAAI,CAAC;EAE/C,IAAI,CAAC,IAAAW,4BAAkB,EAACT,QAAQ,EAAE;IAAEG,QAAQ;IAAEG;EAAK,CAAC,CAAC,EAAE;IACrD;IACA;IACAI,eAAK,CAACC,MAAM,CAACC,MAAM,CAACC,IAAI,CAAC,aAAa,CAAC,EAAE,0CAA0C,CAAC;IACpF,OAAO,SAAS;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
@@ -24,96 +24,98 @@ class AllureCucumberWorld extends _cucumber.World {
24
24
  /**
25
25
  * @deprecated please use import { label } from "allure-js-commons" instead.
26
26
  */
27
- _defineProperty(this, "label", (name, value) => allure.label(name, value));
27
+ _defineProperty(this, "label", (name, value) => Promise.resolve(allure.label(name, value)));
28
28
  /**
29
29
  * @deprecated please use import { link } from "allure-js-commons" instead.
30
30
  */
31
- _defineProperty(this, "link", (type, url, name) => allure.link(url, type, name));
31
+ _defineProperty(this, "link", (type, url, name) => Promise.resolve(allure.link(url, name, type)));
32
32
  /**
33
33
  * @deprecated please use import { parameter } from "allure-js-commons" instead.
34
34
  */
35
- _defineProperty(this, "parameter", (name, value, options) => allure.parameter(name, value, options));
35
+ _defineProperty(this, "parameter", (name, value, options) => Promise.resolve(allure.parameter(name, value, options)));
36
36
  /**
37
37
  * @deprecated please use import { description } from "allure-js-commons" instead.
38
38
  */
39
- _defineProperty(this, "description", value => allure.description(value));
39
+ _defineProperty(this, "description", value => Promise.resolve(allure.description(value)));
40
40
  /**
41
41
  * @deprecated please use import { descriptionHtml } from "allure-js-commons" instead.
42
42
  */
43
- _defineProperty(this, "descriptionHtml", html => allure.descriptionHtml(html));
43
+ _defineProperty(this, "descriptionHtml", html => Promise.resolve(allure.descriptionHtml(html)));
44
44
  /**
45
45
  * @deprecated please use import { testCaseId } from "allure-js-commons" instead.
46
46
  */
47
- _defineProperty(this, "testCaseId", id => allure.testCaseId(id));
47
+ _defineProperty(this, "testCaseId", id => Promise.resolve(allure.testCaseId(id)));
48
48
  /**
49
49
  * @deprecated please use import { historyId } from "allure-js-commons" instead.
50
50
  */
51
- _defineProperty(this, "historyId", id => allure.historyId(id));
51
+ _defineProperty(this, "historyId", id => Promise.resolve(allure.historyId(id)));
52
52
  /**
53
53
  * @deprecated please use import { allureId } from "allure-js-commons" instead.
54
54
  */
55
- _defineProperty(this, "allureId", id => allure.allureId(id));
55
+ _defineProperty(this, "allureId", id => Promise.resolve(allure.allureId(id)));
56
56
  /**
57
57
  * @deprecated please use import { displayName } from "allure-js-commons" instead.
58
58
  */
59
- _defineProperty(this, "displayName", name => allure.displayName(name));
59
+ _defineProperty(this, "displayName", name => Promise.resolve(allure.displayName(name)));
60
60
  /**
61
61
  * @deprecated please use import { attachment } from "allure-js-commons" instead.
62
62
  */
63
- _defineProperty(this, "attachment", (name, content, type) => allure.attachment(name, content, type));
63
+ _defineProperty(this, "attachment", (name, content, type) => Promise.resolve(allure.attachment(name, content, {
64
+ contentType: type
65
+ })));
64
66
  /**
65
67
  * @deprecated please use import { issue } from "allure-js-commons" instead.
66
68
  */
67
- _defineProperty(this, "issue", (name, url) => allure.issue(url, name));
69
+ _defineProperty(this, "issue", (name, url) => Promise.resolve(allure.issue(url, name)));
68
70
  /**
69
71
  * @deprecated please use import { tms } from "allure-js-commons" instead.
70
72
  */
71
- _defineProperty(this, "tms", (name, url) => allure.tms(url, name));
73
+ _defineProperty(this, "tms", (name, url) => Promise.resolve(allure.tms(url, name)));
72
74
  /**
73
75
  * @deprecated please use import { epic } from "allure-js-commons" instead.
74
76
  */
75
- _defineProperty(this, "epic", name => allure.epic(name));
77
+ _defineProperty(this, "epic", name => Promise.resolve(allure.epic(name)));
76
78
  /**
77
79
  * @deprecated please use import { feature } from "allure-js-commons" instead.
78
80
  */
79
- _defineProperty(this, "feature", name => allure.feature(name));
81
+ _defineProperty(this, "feature", name => Promise.resolve(allure.feature(name)));
80
82
  /**
81
83
  * @deprecated please use import { story } from "allure-js-commons" instead.
82
84
  */
83
- _defineProperty(this, "story", name => allure.story(name));
85
+ _defineProperty(this, "story", name => Promise.resolve(allure.story(name)));
84
86
  /**
85
87
  * @deprecated please use import { suite } from "allure-js-commons" instead.
86
88
  */
87
- _defineProperty(this, "suite", name => allure.suite(name));
89
+ _defineProperty(this, "suite", name => Promise.resolve(allure.suite(name)));
88
90
  /**
89
91
  * @deprecated please use import { parentSuite } from "allure-js-commons" instead.
90
92
  */
91
- _defineProperty(this, "parentSuite", name => allure.parentSuite(name));
93
+ _defineProperty(this, "parentSuite", name => Promise.resolve(allure.parentSuite(name)));
92
94
  /**
93
95
  * @deprecated please use import { subSuite } from "allure-js-commons" instead.
94
96
  */
95
- _defineProperty(this, "subSuite", name => allure.subSuite(name));
97
+ _defineProperty(this, "subSuite", name => Promise.resolve(allure.subSuite(name)));
96
98
  /**
97
99
  * @deprecated please use import { owner } from "allure-js-commons" instead.
98
100
  */
99
- _defineProperty(this, "owner", name => allure.owner(name));
101
+ _defineProperty(this, "owner", name => Promise.resolve(allure.owner(name)));
100
102
  /**
101
103
  * @deprecated please use import { severity } from "allure-js-commons" instead.
102
104
  */
103
- _defineProperty(this, "severity", name => allure.severity(name));
105
+ _defineProperty(this, "severity", name => Promise.resolve(allure.severity(name)));
104
106
  /**
105
107
  * @deprecated please use import { layer } from "allure-js-commons" instead.
106
108
  */
107
- _defineProperty(this, "layer", name => allure.layer(name));
109
+ _defineProperty(this, "layer", name => Promise.resolve(allure.layer(name)));
108
110
  /**
109
111
  * @deprecated please use import { tag } from "allure-js-commons" instead.
110
112
  */
111
- _defineProperty(this, "tag", name => allure.tag(name));
113
+ _defineProperty(this, "tag", name => Promise.resolve(allure.tag(name)));
112
114
  /**
113
115
  * @deprecated please use import { step } from "allure-js-commons" instead.
114
116
  */
115
- _defineProperty(this, "step", (name, body) => allure.step(name, body));
117
+ _defineProperty(this, "step", (name, body) => Promise.resolve(allure.step(name, body)));
116
118
  }
117
119
  }
118
120
  exports.AllureCucumberWorld = AllureCucumberWorld;
119
- //# sourceMappingURL=world.js.map
121
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.js","names":["_cucumber","require","allure","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","AllureCucumberWorld","World","constructor","arguments","name","Promise","resolve","label","type","url","link","options","parameter","description","html","descriptionHtml","id","testCaseId","historyId","allureId","displayName","content","attachment","contentType","issue","tms","epic","feature","story","suite","parentSuite","subSuite","owner","severity","layer","tag","body","step","exports"],"sources":["../../src/legacy.ts"],"sourcesContent":["import { World } from \"@cucumber/cucumber\";\nimport * as allure from \"allure-js-commons\";\nimport type { ParameterOptions } from \"allure-js-commons\";\n\n/**\n * @deprecated please use api exported by \"allure-js-commons\" instead.\n */\nexport interface AllureCucumberLegacyApi {\n label: (name: string, value: string) => Promise<void>;\n link: (type: string, url: string, name?: string) => Promise<void>;\n parameter: (name: string, value: string, options?: ParameterOptions) => Promise<void>;\n description: (markdown: string) => Promise<void>;\n descriptionHtml: (html: string) => Promise<void>;\n testCaseId: (id: string) => Promise<void>;\n historyId: (id: string) => Promise<void>;\n allureId: (id: string) => Promise<void>;\n displayName: (name: string) => Promise<void>;\n attachment: (name: string, content: Buffer | string, type: string) => Promise<void>;\n issue: (name: string, url: string) => Promise<void>;\n tms: (name: string, url: string) => Promise<void>;\n epic: (name: string) => Promise<void>;\n feature: (name: string) => Promise<void>;\n story: (name: string) => Promise<void>;\n suite: (name: string) => Promise<void>;\n parentSuite: (name: string) => Promise<void>;\n subSuite: (name: string) => Promise<void>;\n owner: (name: string) => Promise<void>;\n severity: (name: string) => Promise<void>;\n layer: (name: string) => Promise<void>;\n tag: (name: string) => Promise<void>;\n step: (name: string, body: () => Promise<void>) => Promise<void>;\n}\n\n/**\n * @deprecated please use api exported by \"allure-js-commons\" instead.\n */\nexport class AllureCucumberWorld extends World implements AllureCucumberLegacyApi {\n /**\n * @deprecated please use import { label } from \"allure-js-commons\" instead.\n */\n label = (name: string, value: string) => Promise.resolve(allure.label(name, value));\n /**\n * @deprecated please use import { link } from \"allure-js-commons\" instead.\n */\n link = (type: string, url: string, name?: string) => Promise.resolve(allure.link(url, name, type));\n /**\n * @deprecated please use import { parameter } from \"allure-js-commons\" instead.\n */\n parameter = (name: string, value: string, options?: ParameterOptions) =>\n Promise.resolve(allure.parameter(name, value, options));\n /**\n * @deprecated please use import { description } from \"allure-js-commons\" instead.\n */\n description = (value: string) => Promise.resolve(allure.description(value));\n /**\n * @deprecated please use import { descriptionHtml } from \"allure-js-commons\" instead.\n */\n descriptionHtml = (html: string) => Promise.resolve(allure.descriptionHtml(html));\n /**\n * @deprecated please use import { testCaseId } from \"allure-js-commons\" instead.\n */\n testCaseId = (id: string) => Promise.resolve(allure.testCaseId(id));\n /**\n * @deprecated please use import { historyId } from \"allure-js-commons\" instead.\n */\n historyId = (id: string) => Promise.resolve(allure.historyId(id));\n /**\n * @deprecated please use import { allureId } from \"allure-js-commons\" instead.\n */\n allureId = (id: string) => Promise.resolve(allure.allureId(id));\n /**\n * @deprecated please use import { displayName } from \"allure-js-commons\" instead.\n */\n displayName = (name: string) => Promise.resolve(allure.displayName(name));\n /**\n * @deprecated please use import { attachment } from \"allure-js-commons\" instead.\n */\n attachment = (name: string, content: Buffer | string, type: string) =>\n Promise.resolve(allure.attachment(name, content, { contentType: type }));\n /**\n * @deprecated please use import { issue } from \"allure-js-commons\" instead.\n */\n issue = (name: string, url: string) => Promise.resolve(allure.issue(url, name));\n /**\n * @deprecated please use import { tms } from \"allure-js-commons\" instead.\n */\n tms = (name: string, url: string) => Promise.resolve(allure.tms(url, name));\n /**\n * @deprecated please use import { epic } from \"allure-js-commons\" instead.\n */\n epic = (name: string) => Promise.resolve(allure.epic(name));\n /**\n * @deprecated please use import { feature } from \"allure-js-commons\" instead.\n */\n feature = (name: string) => Promise.resolve(allure.feature(name));\n /**\n * @deprecated please use import { story } from \"allure-js-commons\" instead.\n */\n story = (name: string) => Promise.resolve(allure.story(name));\n /**\n * @deprecated please use import { suite } from \"allure-js-commons\" instead.\n */\n suite = (name: string) => Promise.resolve(allure.suite(name));\n /**\n * @deprecated please use import { parentSuite } from \"allure-js-commons\" instead.\n */\n parentSuite = (name: string) => Promise.resolve(allure.parentSuite(name));\n /**\n * @deprecated please use import { subSuite } from \"allure-js-commons\" instead.\n */\n subSuite = (name: string) => Promise.resolve(allure.subSuite(name));\n /**\n * @deprecated please use import { owner } from \"allure-js-commons\" instead.\n */\n owner = (name: string) => Promise.resolve(allure.owner(name));\n /**\n * @deprecated please use import { severity } from \"allure-js-commons\" instead.\n */\n severity = (name: string) => Promise.resolve(allure.severity(name));\n /**\n * @deprecated please use import { layer } from \"allure-js-commons\" instead.\n */\n layer = (name: string) => Promise.resolve(allure.layer(name));\n /**\n * @deprecated please use import { tag } from \"allure-js-commons\" instead.\n */\n tag = (name: string) => Promise.resolve(allure.tag(name));\n /**\n * @deprecated please use import { step } from \"allure-js-commons\" instead.\n */\n step = (name: string, body: () => any) => Promise.resolve(allure.step(name, body));\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA4C,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,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C+D,KAAK,CAACzB,IAAI,CAAC,CAAC;IAC7D;AACF;AACA;IAFEhB,eAAA,sBAGegB,IAAY,IAAKC,OAAO,CAACC,OAAO,CAACxC,MAAM,CAACgE,WAAW,CAAC1B,IAAI,CAAC,CAAC;IACzE;AACF;AACA;IAFEhB,eAAA,mBAGYgB,IAAY,IAAKC,OAAO,CAACC,OAAO,CAACxC,MAAM,CAACiE,QAAQ,CAAC3B,IAAI,CAAC,CAAC;IACnE;AACF;AACA;IAFEhB,eAAA,gBAGSgB,IAAY,IAAKC,OAAO,CAACC,OAAO,CAACxC,MAAM,CAACkE,KAAK,CAAC5B,IAAI,CAAC,CAAC;IAC7D;AACF;AACA;IAFEhB,eAAA,mBAGYgB,IAAY,IAAKC,OAAO,CAACC,OAAO,CAACxC,MAAM,CAACmE,QAAQ,CAAC7B,IAAI,CAAC,CAAC;IACnE;AACF;AACA;IAFEhB,eAAA,gBAGSgB,IAAY,IAAKC,OAAO,CAACC,OAAO,CAACxC,MAAM,CAACoE,KAAK,CAAC9B,IAAI,CAAC,CAAC;IAC7D;AACF;AACA;IAFEhB,eAAA,cAGOgB,IAAY,IAAKC,OAAO,CAACC,OAAO,CAACxC,MAAM,CAACqE,GAAG,CAAC/B,IAAI,CAAC,CAAC;IACzD;AACF;AACA;IAFEhB,eAAA,eAGO,CAACgB,IAAY,EAAEgC,IAAe,KAAK/B,OAAO,CAACC,OAAO,CAACxC,MAAM,CAACuE,IAAI,CAACjC,IAAI,EAAEgC,IAAI,CAAC,CAAC;EAAA;AACpF;AAACE,OAAA,CAAAtC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
package/dist/cjs/model.js CHANGED
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ALLURE_SETUP_REPORTER_HOOK = void 0;
7
+ var ALLURE_SETUP_REPORTER_HOOK = exports.ALLURE_SETUP_REPORTER_HOOK = "__allure_reporter_setup_hook__";
2
8
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","names":[],"sources":["../../src/model.ts"],"sourcesContent":["import type { LabelName, LinkType } from \"allure-js-commons\";\nimport type { Config } from \"allure-js-commons/sdk/reporter\";\n\nexport type LabelConfig = {\n pattern: RegExp[];\n name: LabelName | string;\n};\n\nexport type LinkConfig = {\n pattern: RegExp[];\n urlTemplate: string;\n type: LinkType | string;\n};\n\nexport interface AllureCucumberReporterConfig extends Omit<Config, \"writer\" | \"links\"> {\n testMode?: boolean;\n links?: LinkConfig[];\n labels?: LabelConfig[];\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"model.js","names":["ALLURE_SETUP_REPORTER_HOOK","exports"],"sources":["../../src/model.ts"],"sourcesContent":["import type { LabelName } from \"allure-js-commons\";\nimport type { LinkConfig, LinkTypeOptions, ReporterConfig } from \"allure-js-commons/sdk/reporter\";\n\nexport const ALLURE_SETUP_REPORTER_HOOK = \"__allure_reporter_setup_hook__\";\n\nexport type LabelConfig = {\n pattern: RegExp[];\n name: LabelName | string;\n};\n\nexport type AllureCucumberLinkConfig = LinkConfig<LinkTypeOptions & { pattern: RegExp[] }>;\n\nexport interface AllureCucumberReporterConfig extends Omit<ReporterConfig, \"links\"> {\n links?: AllureCucumberLinkConfig;\n labels?: LabelConfig[];\n}\n"],"mappings":";;;;;;AAGO,IAAMA,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,GAAG,gCAAgC","ignoreList":[]}
@@ -7,11 +7,13 @@ exports.default = void 0;
7
7
  var _cucumber = require("@cucumber/cucumber");
8
8
  var _messages = require("@cucumber/messages");
9
9
  var _nodeOs = _interopRequireDefault(require("node:os"));
10
+ var _nodePath = require("node:path");
10
11
  var _nodeProcess = _interopRequireDefault(require("node:process"));
11
12
  var _allureJsCommons = require("allure-js-commons");
13
+ var _sdk = require("allure-js-commons/sdk");
12
14
  var _reporter = require("allure-js-commons/sdk/reporter");
13
- var _world = require("./world.js");
14
- var _excluded = ["resultsDir", "testMode", "links", "labels"];
15
+ var _legacy = require("./legacy.js");
16
+ var _excluded = ["resultsDir", "links", "labels"];
15
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -26,47 +28,49 @@ var {
26
28
  class AllureCucumberReporter extends _cucumber.Formatter {
27
29
  constructor(options) {
28
30
  super(options);
29
- _defineProperty(this, "afterHooks", void 0);
30
- _defineProperty(this, "beforeHooks", void 0);
31
- _defineProperty(this, "linksConfigs", []);
31
+ _defineProperty(this, "afterHooks", {});
32
+ _defineProperty(this, "beforeHooks", {});
33
+ _defineProperty(this, "linksConfigs", {});
32
34
  _defineProperty(this, "labelsConfigs", []);
33
- _defineProperty(this, "runtime", void 0);
35
+ _defineProperty(this, "allureRuntime", void 0);
34
36
  _defineProperty(this, "documentMap", new Map());
35
37
  _defineProperty(this, "scenarioMap", new Map());
36
38
  _defineProperty(this, "stepMap", new Map());
37
39
  _defineProperty(this, "testStepMap", new Map());
38
40
  _defineProperty(this, "pickleStepMap", new Map());
39
- _defineProperty(this, "testCaseTestStepsResults", new Map());
40
41
  _defineProperty(this, "pickleMap", new Map());
41
- _defineProperty(this, "hookMap", new Map());
42
42
  _defineProperty(this, "testCaseMap", new Map());
43
43
  _defineProperty(this, "testCaseStartedMap", new Map());
44
- _defineProperty(this, "allureResultsUuids", new Map());
44
+ _defineProperty(this, "testResultUuids", new Map());
45
+ _defineProperty(this, "scopeUuids", new Map());
46
+ _defineProperty(this, "fixtureUuids", new Map());
45
47
  var _ref = options.parsedArgvOptions,
46
48
  {
47
- resultsDir = "./allure-results",
48
- testMode,
49
+ resultsDir,
49
50
  links,
50
51
  labels
51
52
  } = _ref,
52
53
  rest = _objectWithoutProperties(_ref, _excluded);
53
- this.runtime = new _reporter.ReporterRuntime(_objectSpread({
54
- writer: testMode ? new _reporter.MessageWriter() : new _reporter.FileSystemWriter({
54
+ this.allureRuntime = new _reporter.ReporterRuntime(_objectSpread({
55
+ writer: (0, _reporter.createDefaultWriter)({
55
56
  resultsDir
56
57
  }),
57
- links: links
58
+ links
58
59
  }, rest));
59
- this.linksConfigs = links || [];
60
+ this.linksConfigs = links || {};
60
61
  this.labelsConfigs = labels || [];
61
62
  options.eventBroadcaster.on("envelope", this.parseEnvelope.bind(this));
62
- this.beforeHooks = options.supportCodeLibrary.beforeTestCaseHookDefinitions;
63
- this.afterHooks = options.supportCodeLibrary.afterTestCaseHookDefinitions;
64
-
63
+ this.beforeHooks = options.supportCodeLibrary.beforeTestCaseHookDefinitions.reduce((acc, hook) => Object.assign(acc, {
64
+ [hook.id]: hook
65
+ }), {});
66
+ this.afterHooks = options.supportCodeLibrary.afterTestCaseHookDefinitions.reduce((acc, hook) => Object.assign(acc, {
67
+ [hook.id]: hook
68
+ }), {});
65
69
  // set AllureCucumberWorld for single thread mode
66
70
  if (options.supportCodeLibrary.World === _cucumber.World) {
67
71
  // @ts-ignore
68
72
  // noinspection JSConstantReassignment
69
- options.supportCodeLibrary.World = _world.AllureCucumberWorld;
73
+ options.supportCodeLibrary.World = _legacy.AllureCucumberWorld;
70
74
  }
71
75
  }
72
76
  get tagsIgnorePatterns() {
@@ -74,10 +78,14 @@ class AllureCucumberReporter extends _cucumber.Formatter {
74
78
  labelsConfigs,
75
79
  linksConfigs
76
80
  } = this;
77
- return [...labelsConfigs, ...linksConfigs].flatMap(_ref2 => {
81
+ var linkConfigEntries = Object.entries(linksConfigs).map(_ref2 => {
82
+ var [, v] = _ref2;
83
+ return v;
84
+ });
85
+ return [...labelsConfigs, ...linkConfigEntries].flatMap(_ref3 => {
78
86
  var {
79
87
  pattern
80
- } = _ref2;
88
+ } = _ref3;
81
89
  return pattern;
82
90
  });
83
91
  }
@@ -101,15 +109,15 @@ class AllureCucumberReporter extends _cucumber.Formatter {
101
109
  case !!envelope.attachment:
102
110
  this.onAttachment(envelope.attachment);
103
111
  break;
104
- case !!envelope.hook:
105
- this.onHook(envelope.hook);
106
- break;
107
112
  case !!envelope.testStepStarted:
108
113
  this.onTestStepStarted(envelope.testStepStarted);
109
114
  break;
110
115
  case !!envelope.testStepFinished:
111
116
  this.onTestStepFinished(envelope.testStepFinished);
112
117
  break;
118
+ case !!envelope.testRunFinished:
119
+ this.onTestRunFinished();
120
+ break;
113
121
  }
114
122
  }
115
123
  parseTagsLabels(tags) {
@@ -139,16 +147,17 @@ class AllureCucumberReporter extends _cucumber.Formatter {
139
147
  parseTagsLinks(tags) {
140
148
  var tagKeyRe = /^@\S+=/;
141
149
  var links = [];
142
- if (this.linksConfigs.length === 0) {
150
+ if (Object.keys(this.linksConfigs).length === 0) {
143
151
  return links;
144
152
  }
145
- this.linksConfigs.forEach(matcher => {
153
+ Object.entries(this.linksConfigs).forEach(_ref4 => {
154
+ var [type, matcher] = _ref4;
146
155
  var matchedTags = tags.filter(tag => matcher.pattern.some(pattern => pattern.test(tag.name)));
147
156
  var matchedLinks = matchedTags.map(tag => {
148
157
  var tagValue = tag.name.replace(tagKeyRe, "");
149
158
  return {
150
- url: matcher.urlTemplate.replace(/%s$/, tagValue) || tagValue,
151
- type: matcher.type
159
+ url: (0, _reporter.applyLinkTemplate)(matcher.urlTemplate, tagValue) || tagValue,
160
+ type
152
161
  };
153
162
  });
154
163
  links.push(...matchedLinks);
@@ -217,9 +226,10 @@ class AllureCucumberReporter extends _cucumber.Formatter {
217
226
  labels: [],
218
227
  links: [],
219
228
  testCaseId: (0, _reporter.md5)(fullName),
220
- start: Date.now(),
229
+ start: data.timestamp.nanos / 1000,
221
230
  fullName
222
231
  };
232
+ result.labels.push(...(0, _reporter.getEnvironmentLabels)());
223
233
  result.labels.push({
224
234
  name: _allureJsCommons.LabelName.HOST,
225
235
  value: _nodeOs.default.hostname()
@@ -239,12 +249,6 @@ class AllureCucumberReporter extends _cucumber.Formatter {
239
249
  value: doc.feature.name
240
250
  });
241
251
  }
242
- if (scenario) {
243
- result.labels.push({
244
- name: _allureJsCommons.LabelName.SUITE,
245
- value: scenario.name
246
- });
247
- }
248
252
  var pickleLabels = this.parsePickleTags(pickle.tags || []);
249
253
  var featureLabels = this.parseTagsLabels((doc === null || doc === void 0 || (_doc$feature2 = doc.feature) === null || _doc$feature2 === void 0 ? void 0 : _doc$feature2.tags) || []);
250
254
  var featureLinks = this.parseTagsLinks((doc === null || doc === void 0 || (_doc$feature3 = doc.feature) === null || _doc$feature3 === void 0 ? void 0 : _doc$feature3.tags) || []);
@@ -252,9 +256,11 @@ class AllureCucumberReporter extends _cucumber.Formatter {
252
256
  var scenarioLinks = this.parseTagsLinks((scenario === null || scenario === void 0 ? void 0 : scenario.tags) || []);
253
257
  result.labels.push(...featureLabels, ...scenarioLabels, ...pickleLabels);
254
258
  result.links.push(...featureLinks, ...scenarioLinks);
255
- var testUuid = this.runtime.startTest(result);
259
+ var scopeUuid = this.allureRuntime.startScope();
260
+ this.scopeUuids.set(data.id, scopeUuid);
261
+ var testUuid = this.allureRuntime.startTest(result, [scopeUuid]);
262
+ this.testResultUuids.set(data.id, testUuid);
256
263
  this.testCaseStartedMap.set(data.id, data);
257
- this.allureResultsUuids.set(data.id, testUuid);
258
264
  if (!(scenario !== null && scenario !== void 0 && scenario.examples)) {
259
265
  return;
260
266
  }
@@ -266,19 +272,18 @@ class AllureCucumberReporter extends _cucumber.Formatter {
266
272
  return;
267
273
  }
268
274
  var csvDataTable = "".concat(csvDataTableHeader, "\n").concat(csvDataTableBody, "\n");
269
-
270
- // TODO: actually we don't need to write the same attachment multiple times, just need to keep them in Map and then re-use for each test
271
- this.runtime.writeAttachment({
272
- name: "Examples",
273
- content: csvDataTable,
275
+ this.allureRuntime.writeAttachment(testUuid, null, "Examples", Buffer.from(csvDataTable, "utf-8"), {
274
276
  contentType: _allureJsCommons.ContentType.CSV,
275
- encoding: "utf8"
276
- }, testUuid);
277
+ fileExtension: ".csv"
278
+ });
277
279
  });
278
280
  }
279
281
  onTestCaseFinished(data) {
280
- var testUuid = this.allureResultsUuids.get(data.testCaseStartedId);
281
- this.runtime.updateTest(result => {
282
+ var testUuid = this.testResultUuids.get(data.testCaseStartedId);
283
+ if (!testUuid) {
284
+ return;
285
+ }
286
+ this.allureRuntime.updateTest(testUuid, result => {
282
287
  result.status = result.steps.length > 0 ? (0, _reporter.getWorstStepResultStatus)(result.steps) : _allureJsCommons.Status.PASSED;
283
288
  result.stage = _allureJsCommons.Stage.FINISHED;
284
289
  if (result.status === undefined) {
@@ -286,19 +291,47 @@ class AllureCucumberReporter extends _cucumber.Formatter {
286
291
  message: "The test doesn't have an implementation."
287
292
  };
288
293
  }
289
- }, testUuid);
290
- this.runtime.stopTest({
291
- uuid: testUuid,
292
- stop: Date.now()
293
294
  });
294
- this.runtime.writeTest(testUuid);
295
+ this.allureRuntime.stopTest(testUuid, {
296
+ stop: data.timestamp.nanos / 1000
297
+ });
298
+ this.allureRuntime.writeTest(testUuid);
299
+ this.testResultUuids.delete(data.testCaseStartedId);
300
+ var scopeUuid = this.scopeUuids.get(data.testCaseStartedId);
301
+ if (scopeUuid) {
302
+ this.allureRuntime.writeScope(scopeUuid);
303
+ this.scopeUuids.delete(data.testCaseStartedId);
304
+ }
295
305
  }
296
306
  onTestStepStarted(data) {
297
307
  var _stepPickle$argument;
298
- var testUuid = this.allureResultsUuids.get(data.testCaseStartedId);
308
+ var testUuid = this.testResultUuids.get(data.testCaseStartedId);
299
309
  var step = this.testStepMap.get(data.testStepId);
300
-
301
- // TODO: support hooks reporting
310
+ if (step.hookId) {
311
+ var scopeUuid = this.scopeUuids.get(data.testCaseStartedId);
312
+ if (!scopeUuid) {
313
+ return;
314
+ }
315
+ var beforeHook = step.hookId && this.beforeHooks[step.hookId];
316
+ var afterHook = step.hookId && this.afterHooks[step.hookId];
317
+ var type = beforeHook ? "before" : afterHook ? "after" : undefined;
318
+ if (!type) {
319
+ return;
320
+ }
321
+ var name = beforeHook ? beforeHook.name : afterHook ? afterHook.name : "hook";
322
+ if (name === "ALLURE_FIXTURE_IGNORE") {
323
+ return;
324
+ }
325
+ var fixtureUuid = this.allureRuntime.startFixture(scopeUuid, type, {
326
+ name,
327
+ stage: _allureJsCommons.Stage.RUNNING,
328
+ start: data.timestamp.nanos / 1000
329
+ });
330
+ if (fixtureUuid) {
331
+ this.fixtureUuids.set(data.testCaseStartedId, fixtureUuid);
332
+ }
333
+ return;
334
+ }
302
335
  if (!step.pickleStepId) {
303
336
  return;
304
337
  }
@@ -307,76 +340,117 @@ class AllureCucumberReporter extends _cucumber.Formatter {
307
340
  return;
308
341
  }
309
342
  var stepKeyword = stepPickle.astNodeIds.map(astNodeId => this.stepMap.get(astNodeId)).map(stepAstNode => stepAstNode === null || stepAstNode === void 0 ? void 0 : stepAstNode.keyword).find(keyword => keyword !== undefined) || "";
310
- var stepResult = _objectSpread(_objectSpread({}, (0, _reporter.createStepResult)()), {}, {
343
+ var stepUuid = this.allureRuntime.startStep(testUuid, undefined, _objectSpread(_objectSpread({}, (0, _reporter.createStepResult)()), {}, {
311
344
  name: "".concat(stepKeyword).concat(stepPickle.text),
312
- start: data.timestamp.nanos
313
- });
314
- this.runtime.startStep(stepResult, testUuid);
345
+ start: data.timestamp.nanos / 1000
346
+ }));
315
347
  if (!((_stepPickle$argument = stepPickle.argument) !== null && _stepPickle$argument !== void 0 && _stepPickle$argument.dataTable)) {
316
348
  return;
317
349
  }
318
350
  var csvDataTable = stepPickle.argument.dataTable.rows.reduce((acc, row) => "".concat(acc + row.cells.map(cell => cell.value).join(","), "\n"), "");
319
- this.runtime.writeAttachment({
320
- name: "Data table",
321
- content: csvDataTable,
351
+ this.allureRuntime.writeAttachment(testUuid, stepUuid, "Data table", Buffer.from(csvDataTable, "utf-8"), {
322
352
  contentType: _allureJsCommons.ContentType.CSV,
323
- encoding: "utf8"
324
- }, testUuid);
353
+ fileExtension: ".csv"
354
+ });
325
355
  }
326
356
  onTestStepFinished(data) {
327
- var testUuid = this.allureResultsUuids.get(data.testCaseStartedId);
328
- var currentStep = this.runtime.getCurrentStep(testUuid);
329
-
330
- // TODO: support hooks reporting
357
+ var step = this.testStepMap.get(data.testStepId);
358
+ if (!step) {
359
+ return;
360
+ }
361
+ var status = this.parseStatus(data.testStepResult);
362
+ var stage = status !== _allureJsCommons.Status.SKIPPED ? _allureJsCommons.Stage.FINISHED : _allureJsCommons.Stage.PENDING;
363
+ if (step.hookId) {
364
+ var fixtureUuid = this.fixtureUuids.get(data.testCaseStartedId);
365
+ if (!fixtureUuid) {
366
+ return;
367
+ }
368
+ this.allureRuntime.updateFixture(fixtureUuid, r => {
369
+ r.stage = stage;
370
+ r.status = status;
371
+ if (data.testStepResult.exception) {
372
+ r.statusDetails = (0, _sdk.getMessageAndTraceFromError)({
373
+ message: data.testStepResult.message,
374
+ stack: data.testStepResult.exception.stackTrace
375
+ });
376
+ }
377
+ });
378
+ this.allureRuntime.stopFixture(fixtureUuid, {
379
+ stop: data.timestamp.nanos / 1000
380
+ });
381
+ this.fixtureUuids.delete(data.testCaseStartedId);
382
+ return;
383
+ }
384
+ var testUuid = this.testResultUuids.get(data.testCaseStartedId);
385
+ var currentStep = this.allureRuntime.currentStep(testUuid);
331
386
  if (!currentStep) {
332
387
  return;
333
388
  }
334
- this.runtime.updateStep(step => {
335
- var status = this.parseStatus(data.testStepResult);
336
- step.status = status;
337
- step.stage = status !== _allureJsCommons.Status.SKIPPED ? _allureJsCommons.Stage.FINISHED : _allureJsCommons.Stage.PENDING;
389
+ this.allureRuntime.updateStep(currentStep, r => {
390
+ r.status = status;
391
+ r.stage = stage;
338
392
  if (status === undefined) {
339
- step.statusDetails = {
393
+ r.statusDetails = {
340
394
  message: "The step doesn't have an implementation."
341
395
  };
342
396
  return;
343
397
  }
344
398
  if (data.testStepResult.exception) {
345
- step.statusDetails = {
399
+ r.statusDetails = {
346
400
  message: data.testStepResult.message,
347
401
  trace: data.testStepResult.exception.stackTrace
348
402
  };
349
403
  }
350
- }, testUuid);
351
- this.runtime.stopStep({
352
- uuid: testUuid,
353
- stop: currentStep.start + data.timestamp.nanos
354
404
  });
355
- }
356
- onHook(data) {
357
- this.hookMap.set(data.id, data);
405
+ this.allureRuntime.stopStep(currentStep, {
406
+ stop: data.timestamp.nanos / 1000
407
+ });
358
408
  }
359
409
  onAttachment(message) {
410
+ var _message$fileName;
360
411
  if (!message.testCaseStartedId) {
361
412
  return;
362
413
  }
363
- var testUuid = this.allureResultsUuids.get(message.testCaseStartedId);
414
+ var fixtureUuid = this.fixtureUuids.get(message.testCaseStartedId);
415
+ var testUuid = this.testResultUuids.get(message.testCaseStartedId);
416
+ var rootUuid = fixtureUuid !== null && fixtureUuid !== void 0 ? fixtureUuid : testUuid;
417
+ if (!rootUuid) {
418
+ return;
419
+ }
420
+ if (message.mediaType === "application/vnd.allure.skipcucumber+json") {
421
+ if (testUuid) {
422
+ this.allureRuntime.updateTest(testUuid, result => {
423
+ result.labels.push({
424
+ name: "ALLURE_TESTPLAN_SKIP",
425
+ value: "true"
426
+ });
427
+ });
428
+ }
429
+ return;
430
+ }
364
431
  if (message.mediaType === _reporter.ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE) {
365
432
  var parsedMessage = JSON.parse(message.body);
366
- this.runtime.applyRuntimeMessages(Array.isArray(parsedMessage) ? parsedMessage : [parsedMessage], {
367
- testUuid
368
- });
433
+
434
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
435
+ this.allureRuntime.applyRuntimeMessages(rootUuid, Array.isArray(parsedMessage) ? parsedMessage : [parsedMessage]);
369
436
  return;
370
437
  }
371
-
372
- // only pass through valid encodings
373
- var encoding = Buffer.isEncoding(message.contentEncoding) ? message.contentEncoding : "utf8";
374
- this.runtime.writeAttachment({
375
- name: "Attachment",
376
- content: message.body,
377
- contentType: message.mediaType,
378
- encoding
379
- }, testUuid);
438
+ var encoding = message.contentEncoding === _messages.AttachmentContentEncoding.BASE64 ? "base64" : "utf-8";
439
+ this.allureRuntime.applyRuntimeMessages(rootUuid, [{
440
+ type: "attachment_content",
441
+ data: {
442
+ name: (_message$fileName = message.fileName) !== null && _message$fileName !== void 0 ? _message$fileName : "Attachment",
443
+ content: Buffer.from(message.body, encoding).toString("base64"),
444
+ encoding: "base64",
445
+ contentType: message.mediaType,
446
+ fileExtension: message.fileName ? (0, _nodePath.extname)(message.fileName) : undefined,
447
+ wrapInStep: true
448
+ }
449
+ }]);
450
+ }
451
+ onTestRunFinished() {
452
+ this.allureRuntime.writeCategoriesDefinitions();
453
+ this.allureRuntime.writeEnvironmentInfo();
380
454
  }
381
455
  }
382
456
  exports.default = AllureCucumberReporter;