allure-codeceptjs 3.0.9 → 3.2.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/dist/cjs/model.js.map +1 -1
- package/dist/cjs/reporter.js +104 -2
- package/dist/cjs/reporter.js.map +1 -1
- package/dist/esm/model.js.map +1 -1
- package/dist/esm/reporter.js +105 -3
- package/dist/esm/reporter.js.map +1 -1
- package/dist/types/model.d.ts +8 -0
- package/dist/types/reporter.d.ts +12 -1
- package/package.json +5 -5
package/dist/cjs/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","names":[],"sources":["../../src/model.ts"],"sourcesContent":["export interface CodeceptError {\n params: any;\n template: string;\n showDiff: boolean;\n actual: string;\n expected: string;\n cliMessage: () => string;\n message: string;\n inspect: () => string;\n}\n\nexport interface CodeceptStep {\n actor: string;\n name: string;\n helperMethod: string;\n suffix: string;\n prefix: string;\n comment: string;\n args: string[];\n status: string;\n metaStep: CodeceptStep;\n toString: () => string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"model.js","names":[],"sources":["../../src/model.ts"],"sourcesContent":["export interface CodeceptError {\n params: any;\n template: string;\n showDiff: boolean;\n actual: string;\n expected: string;\n cliMessage: () => string;\n message: string;\n inspect: () => string;\n}\n\nexport interface CodeceptStep {\n actor: string;\n name: string;\n helperMethod: string;\n suffix: string;\n prefix: string;\n comment: string;\n args: string[];\n status: string;\n metaStep: CodeceptStep;\n toString: () => string;\n isBDD: () => boolean;\n}\n\nexport interface CodeceptBddStep {\n id: string;\n keyword: string;\n keywordType: string;\n text: string;\n startTime: number;\n}\n"],"mappings":"","ignoreList":[]}
|
package/dist/cjs/reporter.js
CHANGED
|
@@ -15,9 +15,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
15
15
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
16
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
var MAX_META_STEP_NESTING = 10;
|
|
18
19
|
class AllureCodeceptJsReporter extends _allureMocha.default {
|
|
19
20
|
constructor(runner, opts, isInWorker) {
|
|
20
21
|
super(runner, opts, isInWorker);
|
|
22
|
+
_defineProperty(this, "currentBddStep", void 0);
|
|
23
|
+
_defineProperty(this, "metaStepStack", []);
|
|
21
24
|
_defineProperty(this, "getFrameworkName", () => "codeceptjs");
|
|
22
25
|
_defineProperty(this, "getWorkerId", () => undefined);
|
|
23
26
|
this.registerEvents();
|
|
@@ -25,11 +28,15 @@ class AllureCodeceptJsReporter extends _allureMocha.default {
|
|
|
25
28
|
registerEvents() {
|
|
26
29
|
// Test
|
|
27
30
|
_codeceptjs.event.dispatcher.on(_codeceptjs.event.test.before, this.testStarted.bind(this));
|
|
31
|
+
_codeceptjs.event.dispatcher.on(_codeceptjs.event.test.failed, this.testFailed.bind(this));
|
|
32
|
+
_codeceptjs.event.dispatcher.on(_codeceptjs.event.test.finished, this.testFinished.bind(this));
|
|
28
33
|
// Step
|
|
29
34
|
_codeceptjs.event.dispatcher.on(_codeceptjs.event.step.started, this.stepStarted.bind(this));
|
|
30
35
|
_codeceptjs.event.dispatcher.on(_codeceptjs.event.step.passed, this.stepPassed.bind(this));
|
|
31
36
|
_codeceptjs.event.dispatcher.on(_codeceptjs.event.step.failed, this.stepFailed.bind(this));
|
|
32
37
|
_codeceptjs.event.dispatcher.on(_codeceptjs.event.step.comment, this.stepComment.bind(this));
|
|
38
|
+
_codeceptjs.event.dispatcher.on(_codeceptjs.event.bddStep.before, this.bddStepStarted.bind(this));
|
|
39
|
+
_codeceptjs.event.dispatcher.on(_codeceptjs.event.bddStep.after, this.stepPassed.bind(this));
|
|
33
40
|
}
|
|
34
41
|
testStarted(test) {
|
|
35
42
|
if (!this.currentTest) {
|
|
@@ -44,16 +51,108 @@ class AllureCodeceptJsReporter extends _allureMocha.default {
|
|
|
44
51
|
tr.labels.push(...extraTagLabels);
|
|
45
52
|
});
|
|
46
53
|
}
|
|
54
|
+
testFailed(_, error) {
|
|
55
|
+
var status = (0, _sdk.getStatusFromError)({
|
|
56
|
+
message: error.message
|
|
57
|
+
});
|
|
58
|
+
var statusDetails = (0, _sdk.getMessageAndTraceFromError)(error);
|
|
59
|
+
if (this.currentBddStep) {
|
|
60
|
+
this.stopCurrentStep(result => {
|
|
61
|
+
result.stage = _allureJsCommons.Stage.FINISHED;
|
|
62
|
+
result.status = _allureJsCommons.Status.BROKEN;
|
|
63
|
+
if (error) {
|
|
64
|
+
result.status = status;
|
|
65
|
+
result.statusDetails = _objectSpread({}, statusDetails);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
this.currentBddStep = undefined;
|
|
70
|
+
for (var {
|
|
71
|
+
id
|
|
72
|
+
} of this.metaStepStack) {
|
|
73
|
+
this.runtime.updateStep(id, result => {
|
|
74
|
+
result.stage = _allureJsCommons.Stage.FINISHED;
|
|
75
|
+
result.status = _allureJsCommons.Status.BROKEN;
|
|
76
|
+
if (error) {
|
|
77
|
+
result.status = status;
|
|
78
|
+
result.statusDetails = _objectSpread({}, statusDetails);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
this.runtime.stopStep(id);
|
|
82
|
+
}
|
|
83
|
+
this.metaStepStack = [];
|
|
84
|
+
}
|
|
85
|
+
testFinished() {
|
|
86
|
+
if (this.currentBddStep) {
|
|
87
|
+
this.runtime.updateStep(this.currentBddStep, result => {
|
|
88
|
+
result.status = _allureJsCommons.Status.PASSED;
|
|
89
|
+
result.stage = _allureJsCommons.Stage.FINISHED;
|
|
90
|
+
});
|
|
91
|
+
this.runtime.stopStep(this.currentBddStep);
|
|
92
|
+
}
|
|
93
|
+
this.currentBddStep = undefined;
|
|
94
|
+
for (var {
|
|
95
|
+
id
|
|
96
|
+
} of this.metaStepStack) {
|
|
97
|
+
this.runtime.updateStep(id, result => {
|
|
98
|
+
result.status = _allureJsCommons.Status.PASSED;
|
|
99
|
+
result.stage = _allureJsCommons.Stage.FINISHED;
|
|
100
|
+
});
|
|
101
|
+
this.runtime.stopStep(id);
|
|
102
|
+
}
|
|
103
|
+
this.metaStepStack = [];
|
|
104
|
+
}
|
|
47
105
|
stepStarted(step) {
|
|
48
106
|
var _this$currentHook;
|
|
49
107
|
var root = (_this$currentHook = this.currentHook) !== null && _this$currentHook !== void 0 ? _this$currentHook : this.currentTest;
|
|
50
108
|
if (!root) {
|
|
51
109
|
return;
|
|
52
110
|
}
|
|
111
|
+
var stepPath = [];
|
|
112
|
+
var current = step.metaStep;
|
|
113
|
+
while (current && !current.isBDD() && stepPath.length < MAX_META_STEP_NESTING) {
|
|
114
|
+
var _current$toString;
|
|
115
|
+
stepPath.push((0, _sdk.stripAnsi)((_current$toString = current.toString()) !== null && _current$toString !== void 0 ? _current$toString : "").trim());
|
|
116
|
+
current = current.metaStep;
|
|
117
|
+
}
|
|
118
|
+
var index = 0;
|
|
119
|
+
while (index < Math.min(this.metaStepStack.length, stepPath.length) && this.metaStepStack[index].name === stepPath[index]) {
|
|
120
|
+
index++;
|
|
121
|
+
}
|
|
122
|
+
for (var i = index; i < this.metaStepStack.length; i++) {
|
|
123
|
+
var id = this.metaStepStack[i].id;
|
|
124
|
+
this.runtime.updateStep(id, result => {
|
|
125
|
+
result.status = _allureJsCommons.Status.PASSED;
|
|
126
|
+
result.stage = _allureJsCommons.Stage.FINISHED;
|
|
127
|
+
});
|
|
128
|
+
this.runtime.stopStep(id);
|
|
129
|
+
}
|
|
130
|
+
for (var _i = index; _i < stepPath.length; _i++) {
|
|
131
|
+
var name = stepPath[_i];
|
|
132
|
+
var _id = this.runtime.startStep(root, undefined, {
|
|
133
|
+
name
|
|
134
|
+
});
|
|
135
|
+
if (_id) {
|
|
136
|
+
this.metaStepStack.push({
|
|
137
|
+
name,
|
|
138
|
+
id: _id
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
53
142
|
this.runtime.startStep(root, undefined, {
|
|
54
143
|
name: step.toString().trim()
|
|
55
144
|
});
|
|
56
145
|
}
|
|
146
|
+
bddStepStarted(step) {
|
|
147
|
+
var _this$currentHook2;
|
|
148
|
+
var root = (_this$currentHook2 = this.currentHook) !== null && _this$currentHook2 !== void 0 ? _this$currentHook2 : this.currentTest;
|
|
149
|
+
if (!root) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this.currentBddStep = this.runtime.startStep(root, undefined, {
|
|
153
|
+
name: step.keyword + step.text
|
|
154
|
+
});
|
|
155
|
+
}
|
|
57
156
|
|
|
58
157
|
// according to the docs, codeceptjs supposed to report the error,
|
|
59
158
|
// but actually it's never reported
|
|
@@ -83,9 +182,12 @@ class AllureCodeceptJsReporter extends _allureMocha.default {
|
|
|
83
182
|
});
|
|
84
183
|
}
|
|
85
184
|
stopCurrentStep(updateFunc) {
|
|
86
|
-
var _this$
|
|
87
|
-
var root = (_this$
|
|
185
|
+
var _this$currentHook3;
|
|
186
|
+
var root = (_this$currentHook3 = this.currentHook) !== null && _this$currentHook3 !== void 0 ? _this$currentHook3 : this.currentTest;
|
|
88
187
|
var currentStep = root ? this.runtime.currentStep(root) : undefined;
|
|
188
|
+
this.stopStepById(currentStep, updateFunc);
|
|
189
|
+
}
|
|
190
|
+
stopStepById(currentStep, updateFunc) {
|
|
89
191
|
if (!currentStep) {
|
|
90
192
|
return;
|
|
91
193
|
}
|
package/dist/cjs/reporter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.js","names":["_codeceptjs","require","_nodeProcess","_allureJsCommons","_sdk","_allureMocha","_interopRequireDefault","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","AllureCodeceptJsReporter","AllureMochaReporter","constructor","runner","opts","isInWorker","undefined","registerEvents","event","dispatcher","on","test","before","testStarted","bind","step","started","stepStarted","passed","stepPassed","failed","stepFailed","comment","stepComment","currentTest","tags","extraTagLabels","tag","isMetadataTag","map","startsWith","substring","trim","name","LabelName","TAG","runtime","updateTest","tr","labels","_this$currentHook","root","currentHook","startStep","toString","_","error","stopCurrentStep","result","stage","Stage","FINISHED","status","getStatusFromError","message","statusDetails","getMessageAndTraceFromError","env","TRY_TO","Status","BROKEN","FAILED","PASSED","updateFunc","_this$currentHook2","currentStep","promise","recorder","catch","err","inspect","Error","updateStep","Promise","reject","stopStep","exports"],"sources":["../../src/reporter.ts"],"sourcesContent":["import { event, recorder } from \"codeceptjs\";\nimport type * as Mocha from \"mocha\";\nimport { env } from \"node:process\";\nimport { LabelName, Stage, Status, type StepResult } from \"allure-js-commons\";\nimport { getMessageAndTraceFromError, getStatusFromError, isMetadataTag } from \"allure-js-commons/sdk\";\nimport AllureMochaReporter from \"allure-mocha\";\nimport type { CodeceptError, CodeceptStep } from \"./model.js\";\n\nexport class AllureCodeceptJsReporter extends AllureMochaReporter {\n constructor(runner: Mocha.Runner, opts: Mocha.MochaOptions, isInWorker: boolean) {\n super(runner, opts, isInWorker);\n this.registerEvents();\n }\n\n registerEvents() {\n // Test\n event.dispatcher.on(event.test.before, this.testStarted.bind(this));\n // Step\n event.dispatcher.on(event.step.started, this.stepStarted.bind(this));\n event.dispatcher.on(event.step.passed, this.stepPassed.bind(this));\n event.dispatcher.on(event.step.failed, this.stepFailed.bind(this));\n event.dispatcher.on(event.step.comment, this.stepComment.bind(this));\n }\n\n testStarted(test: { tags?: string[] }) {\n if (!this.currentTest) {\n return;\n }\n\n const tags = test.tags || [];\n const extraTagLabels = tags\n .filter((tag) => tag && !isMetadataTag(tag))\n .map((tag) => (tag.startsWith(\"@\") ? tag.substring(1) : tag))\n .map((tag) => tag.trim())\n .filter((tag) => tag.length > 0)\n .map((tag) => ({ name: LabelName.TAG, value: tag }));\n\n this.runtime.updateTest(this.currentTest, (tr) => {\n tr.labels.push(...extraTagLabels);\n });\n }\n\n stepStarted(step: CodeceptStep) {\n const root = this.currentHook ?? this.currentTest;\n if (!root) {\n return;\n }\n this.runtime.startStep(root, undefined, {\n name: step.toString().trim(),\n });\n }\n\n // according to the docs, codeceptjs supposed to report the error,\n // but actually it's never reported\n stepFailed(_: CodeceptJS.Step, error?: CodeceptError) {\n this.stopCurrentStep((result) => {\n result.stage = Stage.FINISHED;\n if (error) {\n result.status = getStatusFromError({ message: error.message } as Error);\n result.statusDetails = getMessageAndTraceFromError(error);\n } else {\n result.status = env.TRY_TO === \"true\" ? Status.BROKEN : Status.FAILED;\n }\n });\n }\n\n stepComment() {\n this.stopCurrentStep((result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n }\n\n stepPassed() {\n this.stopCurrentStep((result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n }\n\n stopCurrentStep(updateFunc: (result: StepResult) => void) {\n const root = this.currentHook ?? this.currentTest;\n const currentStep = root ? this.runtime.currentStep(root) : undefined;\n\n if (!currentStep) {\n return;\n }\n const promise = recorder.promise();\n // @ts-ignore\n if (promise) {\n promise.catch((err) => {\n if (!err.message && typeof err.inspect === \"function\") {\n // AssertionFailedError doesn't set message attribute\n err.message = err.inspect();\n }\n if (err instanceof Error || err.constructor.name === \"Error\") {\n this.runtime.updateStep(currentStep, (step) => {\n step.status = getStatusFromError(err as Error);\n step.statusDetails = { ...step.statusDetails, ...getMessageAndTraceFromError(err as Error) };\n });\n }\n return Promise.reject(err);\n });\n }\n\n this.runtime.updateStep(currentStep, updateFunc);\n this.runtime.stopStep(currentStep);\n }\n\n protected getFrameworkName = () => \"codeceptjs\";\n\n protected getWorkerId = () => undefined;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA+C,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,QAAAH,CAAA,EAAAI,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAP,CAAA,OAAAM,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAR,CAAA,GAAAI,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAX,CAAA,EAAAI,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAf,CAAA,aAAAI,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAD,OAAA,CAAAG,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAnB,CAAA,EAAAI,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAArB,CAAA,EAAAM,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GAAY,CAAC;YAC9CtD,IAAI,CAACwC,aAAa,GAAA3E,aAAA,CAAAA,aAAA,KAAQmC,IAAI,CAACwC,aAAa,GAAK,IAAAC,gCAA2B,EAACa,GAAY,CAAC,CAAE;UAC9F,CAAC,CAAC;QACJ;QACA,OAAOI,OAAO,CAACC,MAAM,CAACL,GAAG,CAAC;MAC5B,CAAC,CAAC;IACJ;IAEA,IAAI,CAACjC,OAAO,CAACoC,UAAU,CAACP,WAAW,EAAEF,UAAU,CAAC;IAChD,IAAI,CAAC3B,OAAO,CAACuC,QAAQ,CAACV,WAAW,CAAC;EACpC;AAKF;AAACW,OAAA,CAAA5E,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"reporter.js","names":["_codeceptjs","require","_nodeProcess","_allureJsCommons","_sdk","_allureMocha","_interopRequireDefault","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","MAX_META_STEP_NESTING","AllureCodeceptJsReporter","AllureMochaReporter","constructor","runner","opts","isInWorker","undefined","registerEvents","event","dispatcher","on","test","before","testStarted","bind","failed","testFailed","finished","testFinished","step","started","stepStarted","passed","stepPassed","stepFailed","comment","stepComment","bddStep","bddStepStarted","after","currentTest","tags","extraTagLabels","tag","isMetadataTag","map","startsWith","substring","trim","name","LabelName","TAG","runtime","updateTest","tr","labels","_","error","status","getStatusFromError","message","statusDetails","getMessageAndTraceFromError","currentBddStep","stopCurrentStep","result","stage","Stage","FINISHED","Status","BROKEN","id","metaStepStack","updateStep","stopStep","PASSED","_this$currentHook","root","currentHook","stepPath","current","metaStep","isBDD","_current$toString","stripAnsi","toString","index","Math","min","startStep","_this$currentHook2","keyword","text","env","TRY_TO","FAILED","updateFunc","_this$currentHook3","currentStep","stopStepById","promise","recorder","catch","err","inspect","Error","Promise","reject","exports"],"sources":["../../src/reporter.ts"],"sourcesContent":["import { event, recorder } from \"codeceptjs\";\nimport type * as Mocha from \"mocha\";\nimport { env } from \"node:process\";\nimport { LabelName, Stage, Status, type StepResult } from \"allure-js-commons\";\nimport { getMessageAndTraceFromError, getStatusFromError, isMetadataTag, stripAnsi } from \"allure-js-commons/sdk\";\nimport AllureMochaReporter from \"allure-mocha\";\nimport type { CodeceptBddStep, CodeceptError, CodeceptStep } from \"./model.js\";\n\ninterface MetaStep {\n name: string;\n id: string;\n}\n\nconst MAX_META_STEP_NESTING = 10;\n\nexport class AllureCodeceptJsReporter extends AllureMochaReporter {\n protected currentBddStep?: string;\n protected metaStepStack: MetaStep[] = [];\n\n constructor(runner: Mocha.Runner, opts: Mocha.MochaOptions, isInWorker: boolean) {\n super(runner, opts, isInWorker);\n this.registerEvents();\n }\n\n registerEvents() {\n // Test\n event.dispatcher.on(event.test.before, this.testStarted.bind(this));\n event.dispatcher.on(event.test.failed, this.testFailed.bind(this));\n event.dispatcher.on(event.test.finished, this.testFinished.bind(this));\n // Step\n event.dispatcher.on(event.step.started, this.stepStarted.bind(this));\n event.dispatcher.on(event.step.passed, this.stepPassed.bind(this));\n event.dispatcher.on(event.step.failed, this.stepFailed.bind(this));\n event.dispatcher.on(event.step.comment, this.stepComment.bind(this));\n\n event.dispatcher.on(event.bddStep.before, this.bddStepStarted.bind(this));\n event.dispatcher.on(event.bddStep.after, this.stepPassed.bind(this));\n }\n\n testStarted(test: { tags?: string[] }) {\n if (!this.currentTest) {\n return;\n }\n\n const tags = test.tags || [];\n const extraTagLabels = tags\n .filter((tag) => tag && !isMetadataTag(tag))\n .map((tag) => (tag.startsWith(\"@\") ? tag.substring(1) : tag))\n .map((tag) => tag.trim())\n .filter((tag) => tag.length > 0)\n .map((tag) => ({ name: LabelName.TAG, value: tag }));\n\n this.runtime.updateTest(this.currentTest, (tr) => {\n tr.labels.push(...extraTagLabels);\n });\n }\n\n testFailed(_: {}, error: Error) {\n const status = getStatusFromError({ message: error.message } as Error);\n const statusDetails = getMessageAndTraceFromError(error);\n if (this.currentBddStep) {\n this.stopCurrentStep((result) => {\n result.stage = Stage.FINISHED;\n result.status = Status.BROKEN;\n if (error) {\n result.status = status;\n result.statusDetails = { ...statusDetails };\n }\n });\n }\n this.currentBddStep = undefined;\n\n for (const { id } of this.metaStepStack) {\n this.runtime.updateStep(id, (result) => {\n result.stage = Stage.FINISHED;\n result.status = Status.BROKEN;\n if (error) {\n result.status = status;\n result.statusDetails = { ...statusDetails };\n }\n });\n this.runtime.stopStep(id);\n }\n this.metaStepStack = [];\n }\n\n testFinished() {\n if (this.currentBddStep) {\n this.runtime.updateStep(this.currentBddStep, (result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n this.runtime.stopStep(this.currentBddStep);\n }\n this.currentBddStep = undefined;\n\n for (const { id } of this.metaStepStack) {\n this.runtime.updateStep(id, (result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n this.runtime.stopStep(id);\n }\n\n this.metaStepStack = [];\n }\n\n stepStarted(step: CodeceptStep) {\n const root = this.currentHook ?? this.currentTest;\n if (!root) {\n return;\n }\n\n const stepPath: string[] = [];\n let current = step.metaStep;\n while (current && !current.isBDD() && stepPath.length < MAX_META_STEP_NESTING) {\n stepPath.push(stripAnsi(current.toString() ?? \"\").trim());\n current = current.metaStep;\n }\n\n let index = 0;\n while (\n index < Math.min(this.metaStepStack.length, stepPath.length) &&\n this.metaStepStack[index].name === stepPath[index]\n ) {\n index++;\n }\n\n for (let i = index; i < this.metaStepStack.length; i++) {\n const id = this.metaStepStack[i].id;\n this.runtime.updateStep(id, (result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n this.runtime.stopStep(id);\n }\n\n for (let i = index; i < stepPath.length; i++) {\n const name = stepPath[i];\n const id = this.runtime.startStep(root, undefined, {\n name,\n });\n if (id) {\n this.metaStepStack.push({ name, id });\n }\n }\n\n this.runtime.startStep(root, undefined, {\n name: step.toString().trim(),\n });\n }\n\n bddStepStarted(step: CodeceptBddStep) {\n const root = this.currentHook ?? this.currentTest;\n if (!root) {\n return;\n }\n this.currentBddStep = this.runtime.startStep(root, undefined, {\n name: step.keyword + step.text,\n });\n }\n\n // according to the docs, codeceptjs supposed to report the error,\n // but actually it's never reported\n stepFailed(_: CodeceptJS.Step, error?: CodeceptError) {\n this.stopCurrentStep((result) => {\n result.stage = Stage.FINISHED;\n if (error) {\n result.status = getStatusFromError({ message: error.message } as Error);\n result.statusDetails = getMessageAndTraceFromError(error);\n } else {\n result.status = env.TRY_TO === \"true\" ? Status.BROKEN : Status.FAILED;\n }\n });\n }\n\n stepComment() {\n this.stopCurrentStep((result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n }\n\n stepPassed() {\n this.stopCurrentStep((result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n }\n\n stopCurrentStep(updateFunc: (result: StepResult) => void) {\n const root = this.currentHook ?? this.currentTest;\n const currentStep = root ? this.runtime.currentStep(root) : undefined;\n\n this.stopStepById(currentStep, updateFunc);\n }\n\n stopStepById(currentStep: string | undefined, updateFunc: (result: StepResult) => void) {\n if (!currentStep) {\n return;\n }\n const promise = recorder.promise();\n // @ts-ignore\n if (promise) {\n promise.catch((err) => {\n if (!err.message && typeof err.inspect === \"function\") {\n // AssertionFailedError doesn't set message attribute\n err.message = err.inspect();\n }\n if (err instanceof Error || err.constructor.name === \"Error\") {\n this.runtime.updateStep(currentStep, (step) => {\n step.status = getStatusFromError(err as Error);\n step.statusDetails = { ...step.statusDetails, ...getMessageAndTraceFromError(err as Error) };\n });\n }\n return Promise.reject(err);\n });\n }\n\n this.runtime.updateStep(currentStep, updateFunc);\n this.runtime.stopStep(currentStep);\n }\n\n protected getFrameworkName = () => \"codeceptjs\";\n\n protected getWorkerId = () => undefined;\n}\n"],"mappings":";;;;;;AAAA,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["../../src/model.ts"],"sourcesContent":["export interface CodeceptError {\n params: any;\n template: string;\n showDiff: boolean;\n actual: string;\n expected: string;\n cliMessage: () => string;\n message: string;\n inspect: () => string;\n}\n\nexport interface CodeceptStep {\n actor: string;\n name: string;\n helperMethod: string;\n suffix: string;\n prefix: string;\n comment: string;\n args: string[];\n status: string;\n metaStep: CodeceptStep;\n toString: () => string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"model.js","names":[],"sources":["../../src/model.ts"],"sourcesContent":["export interface CodeceptError {\n params: any;\n template: string;\n showDiff: boolean;\n actual: string;\n expected: string;\n cliMessage: () => string;\n message: string;\n inspect: () => string;\n}\n\nexport interface CodeceptStep {\n actor: string;\n name: string;\n helperMethod: string;\n suffix: string;\n prefix: string;\n comment: string;\n args: string[];\n status: string;\n metaStep: CodeceptStep;\n toString: () => string;\n isBDD: () => boolean;\n}\n\nexport interface CodeceptBddStep {\n id: string;\n keyword: string;\n keywordType: string;\n text: string;\n startTime: number;\n}\n"],"mappings":"","ignoreList":[]}
|
package/dist/esm/reporter.js
CHANGED
|
@@ -6,11 +6,14 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
6
6
|
import { event, recorder } from "codeceptjs";
|
|
7
7
|
import { env } from "node:process";
|
|
8
8
|
import { LabelName, Stage, Status } from "allure-js-commons";
|
|
9
|
-
import { getMessageAndTraceFromError, getStatusFromError, isMetadataTag } from "allure-js-commons/sdk";
|
|
9
|
+
import { getMessageAndTraceFromError, getStatusFromError, isMetadataTag, stripAnsi } from "allure-js-commons/sdk";
|
|
10
10
|
import AllureMochaReporter from "allure-mocha";
|
|
11
|
+
var MAX_META_STEP_NESTING = 10;
|
|
11
12
|
export class AllureCodeceptJsReporter extends AllureMochaReporter {
|
|
12
13
|
constructor(runner, opts, isInWorker) {
|
|
13
14
|
super(runner, opts, isInWorker);
|
|
15
|
+
_defineProperty(this, "currentBddStep", void 0);
|
|
16
|
+
_defineProperty(this, "metaStepStack", []);
|
|
14
17
|
_defineProperty(this, "getFrameworkName", () => "codeceptjs");
|
|
15
18
|
_defineProperty(this, "getWorkerId", () => undefined);
|
|
16
19
|
this.registerEvents();
|
|
@@ -18,11 +21,15 @@ export class AllureCodeceptJsReporter extends AllureMochaReporter {
|
|
|
18
21
|
registerEvents() {
|
|
19
22
|
// Test
|
|
20
23
|
event.dispatcher.on(event.test.before, this.testStarted.bind(this));
|
|
24
|
+
event.dispatcher.on(event.test.failed, this.testFailed.bind(this));
|
|
25
|
+
event.dispatcher.on(event.test.finished, this.testFinished.bind(this));
|
|
21
26
|
// Step
|
|
22
27
|
event.dispatcher.on(event.step.started, this.stepStarted.bind(this));
|
|
23
28
|
event.dispatcher.on(event.step.passed, this.stepPassed.bind(this));
|
|
24
29
|
event.dispatcher.on(event.step.failed, this.stepFailed.bind(this));
|
|
25
30
|
event.dispatcher.on(event.step.comment, this.stepComment.bind(this));
|
|
31
|
+
event.dispatcher.on(event.bddStep.before, this.bddStepStarted.bind(this));
|
|
32
|
+
event.dispatcher.on(event.bddStep.after, this.stepPassed.bind(this));
|
|
26
33
|
}
|
|
27
34
|
testStarted(test) {
|
|
28
35
|
if (!this.currentTest) {
|
|
@@ -37,16 +44,108 @@ export class AllureCodeceptJsReporter extends AllureMochaReporter {
|
|
|
37
44
|
tr.labels.push(...extraTagLabels);
|
|
38
45
|
});
|
|
39
46
|
}
|
|
47
|
+
testFailed(_, error) {
|
|
48
|
+
var status = getStatusFromError({
|
|
49
|
+
message: error.message
|
|
50
|
+
});
|
|
51
|
+
var statusDetails = getMessageAndTraceFromError(error);
|
|
52
|
+
if (this.currentBddStep) {
|
|
53
|
+
this.stopCurrentStep(result => {
|
|
54
|
+
result.stage = Stage.FINISHED;
|
|
55
|
+
result.status = Status.BROKEN;
|
|
56
|
+
if (error) {
|
|
57
|
+
result.status = status;
|
|
58
|
+
result.statusDetails = _objectSpread({}, statusDetails);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
this.currentBddStep = undefined;
|
|
63
|
+
for (var {
|
|
64
|
+
id
|
|
65
|
+
} of this.metaStepStack) {
|
|
66
|
+
this.runtime.updateStep(id, result => {
|
|
67
|
+
result.stage = Stage.FINISHED;
|
|
68
|
+
result.status = Status.BROKEN;
|
|
69
|
+
if (error) {
|
|
70
|
+
result.status = status;
|
|
71
|
+
result.statusDetails = _objectSpread({}, statusDetails);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
this.runtime.stopStep(id);
|
|
75
|
+
}
|
|
76
|
+
this.metaStepStack = [];
|
|
77
|
+
}
|
|
78
|
+
testFinished() {
|
|
79
|
+
if (this.currentBddStep) {
|
|
80
|
+
this.runtime.updateStep(this.currentBddStep, result => {
|
|
81
|
+
result.status = Status.PASSED;
|
|
82
|
+
result.stage = Stage.FINISHED;
|
|
83
|
+
});
|
|
84
|
+
this.runtime.stopStep(this.currentBddStep);
|
|
85
|
+
}
|
|
86
|
+
this.currentBddStep = undefined;
|
|
87
|
+
for (var {
|
|
88
|
+
id
|
|
89
|
+
} of this.metaStepStack) {
|
|
90
|
+
this.runtime.updateStep(id, result => {
|
|
91
|
+
result.status = Status.PASSED;
|
|
92
|
+
result.stage = Stage.FINISHED;
|
|
93
|
+
});
|
|
94
|
+
this.runtime.stopStep(id);
|
|
95
|
+
}
|
|
96
|
+
this.metaStepStack = [];
|
|
97
|
+
}
|
|
40
98
|
stepStarted(step) {
|
|
41
99
|
var _this$currentHook;
|
|
42
100
|
var root = (_this$currentHook = this.currentHook) !== null && _this$currentHook !== void 0 ? _this$currentHook : this.currentTest;
|
|
43
101
|
if (!root) {
|
|
44
102
|
return;
|
|
45
103
|
}
|
|
104
|
+
var stepPath = [];
|
|
105
|
+
var current = step.metaStep;
|
|
106
|
+
while (current && !current.isBDD() && stepPath.length < MAX_META_STEP_NESTING) {
|
|
107
|
+
var _current$toString;
|
|
108
|
+
stepPath.push(stripAnsi((_current$toString = current.toString()) !== null && _current$toString !== void 0 ? _current$toString : "").trim());
|
|
109
|
+
current = current.metaStep;
|
|
110
|
+
}
|
|
111
|
+
var index = 0;
|
|
112
|
+
while (index < Math.min(this.metaStepStack.length, stepPath.length) && this.metaStepStack[index].name === stepPath[index]) {
|
|
113
|
+
index++;
|
|
114
|
+
}
|
|
115
|
+
for (var i = index; i < this.metaStepStack.length; i++) {
|
|
116
|
+
var id = this.metaStepStack[i].id;
|
|
117
|
+
this.runtime.updateStep(id, result => {
|
|
118
|
+
result.status = Status.PASSED;
|
|
119
|
+
result.stage = Stage.FINISHED;
|
|
120
|
+
});
|
|
121
|
+
this.runtime.stopStep(id);
|
|
122
|
+
}
|
|
123
|
+
for (var _i = index; _i < stepPath.length; _i++) {
|
|
124
|
+
var name = stepPath[_i];
|
|
125
|
+
var _id = this.runtime.startStep(root, undefined, {
|
|
126
|
+
name
|
|
127
|
+
});
|
|
128
|
+
if (_id) {
|
|
129
|
+
this.metaStepStack.push({
|
|
130
|
+
name,
|
|
131
|
+
id: _id
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
46
135
|
this.runtime.startStep(root, undefined, {
|
|
47
136
|
name: step.toString().trim()
|
|
48
137
|
});
|
|
49
138
|
}
|
|
139
|
+
bddStepStarted(step) {
|
|
140
|
+
var _this$currentHook2;
|
|
141
|
+
var root = (_this$currentHook2 = this.currentHook) !== null && _this$currentHook2 !== void 0 ? _this$currentHook2 : this.currentTest;
|
|
142
|
+
if (!root) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.currentBddStep = this.runtime.startStep(root, undefined, {
|
|
146
|
+
name: step.keyword + step.text
|
|
147
|
+
});
|
|
148
|
+
}
|
|
50
149
|
|
|
51
150
|
// according to the docs, codeceptjs supposed to report the error,
|
|
52
151
|
// but actually it's never reported
|
|
@@ -76,9 +175,12 @@ export class AllureCodeceptJsReporter extends AllureMochaReporter {
|
|
|
76
175
|
});
|
|
77
176
|
}
|
|
78
177
|
stopCurrentStep(updateFunc) {
|
|
79
|
-
var _this$
|
|
80
|
-
var root = (_this$
|
|
178
|
+
var _this$currentHook3;
|
|
179
|
+
var root = (_this$currentHook3 = this.currentHook) !== null && _this$currentHook3 !== void 0 ? _this$currentHook3 : this.currentTest;
|
|
81
180
|
var currentStep = root ? this.runtime.currentStep(root) : undefined;
|
|
181
|
+
this.stopStepById(currentStep, updateFunc);
|
|
182
|
+
}
|
|
183
|
+
stopStepById(currentStep, updateFunc) {
|
|
82
184
|
if (!currentStep) {
|
|
83
185
|
return;
|
|
84
186
|
}
|
package/dist/esm/reporter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.js","names":["event","recorder","env","LabelName","Stage","Status","getMessageAndTraceFromError","getStatusFromError","isMetadataTag","AllureMochaReporter","AllureCodeceptJsReporter","constructor","runner","opts","isInWorker","_defineProperty","undefined","registerEvents","dispatcher","on","test","before","testStarted","bind","step","started","stepStarted","passed","stepPassed","failed","stepFailed","comment","stepComment","currentTest","tags","extraTagLabels","filter","tag","map","startsWith","substring","trim","length","name","TAG","value","runtime","updateTest","tr","labels","push","_this$currentHook","root","currentHook","startStep","toString","_","error","stopCurrentStep","result","stage","FINISHED","status","message","statusDetails","TRY_TO","BROKEN","FAILED","PASSED","updateFunc","_this$currentHook2","currentStep","promise","catch","err","inspect","Error","updateStep","_objectSpread","Promise","reject","stopStep"],"sources":["../../src/reporter.ts"],"sourcesContent":["import { event, recorder } from \"codeceptjs\";\nimport type * as Mocha from \"mocha\";\nimport { env } from \"node:process\";\nimport { LabelName, Stage, Status, type StepResult } from \"allure-js-commons\";\nimport { getMessageAndTraceFromError, getStatusFromError, isMetadataTag } from \"allure-js-commons/sdk\";\nimport AllureMochaReporter from \"allure-mocha\";\nimport type { CodeceptError, CodeceptStep } from \"./model.js\";\n\nexport class AllureCodeceptJsReporter extends AllureMochaReporter {\n constructor(runner: Mocha.Runner, opts: Mocha.MochaOptions, isInWorker: boolean) {\n super(runner, opts, isInWorker);\n this.registerEvents();\n }\n\n registerEvents() {\n // Test\n event.dispatcher.on(event.test.before, this.testStarted.bind(this));\n // Step\n event.dispatcher.on(event.step.started, this.stepStarted.bind(this));\n event.dispatcher.on(event.step.passed, this.stepPassed.bind(this));\n event.dispatcher.on(event.step.failed, this.stepFailed.bind(this));\n event.dispatcher.on(event.step.comment, this.stepComment.bind(this));\n }\n\n testStarted(test: { tags?: string[] }) {\n if (!this.currentTest) {\n return;\n }\n\n const tags = test.tags || [];\n const extraTagLabels = tags\n .filter((tag) => tag && !isMetadataTag(tag))\n .map((tag) => (tag.startsWith(\"@\") ? tag.substring(1) : tag))\n .map((tag) => tag.trim())\n .filter((tag) => tag.length > 0)\n .map((tag) => ({ name: LabelName.TAG, value: tag }));\n\n this.runtime.updateTest(this.currentTest, (tr) => {\n tr.labels.push(...extraTagLabels);\n });\n }\n\n stepStarted(step: CodeceptStep) {\n const root = this.currentHook ?? this.currentTest;\n if (!root) {\n return;\n }\n this.runtime.startStep(root, undefined, {\n name: step.toString().trim(),\n });\n }\n\n // according to the docs, codeceptjs supposed to report the error,\n // but actually it's never reported\n stepFailed(_: CodeceptJS.Step, error?: CodeceptError) {\n this.stopCurrentStep((result) => {\n result.stage = Stage.FINISHED;\n if (error) {\n result.status = getStatusFromError({ message: error.message } as Error);\n result.statusDetails = getMessageAndTraceFromError(error);\n } else {\n result.status = env.TRY_TO === \"true\" ? Status.BROKEN : Status.FAILED;\n }\n });\n }\n\n stepComment() {\n this.stopCurrentStep((result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n }\n\n stepPassed() {\n this.stopCurrentStep((result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n }\n\n stopCurrentStep(updateFunc: (result: StepResult) => void) {\n const root = this.currentHook ?? this.currentTest;\n const currentStep = root ? this.runtime.currentStep(root) : undefined;\n\n if (!currentStep) {\n return;\n }\n const promise = recorder.promise();\n // @ts-ignore\n if (promise) {\n promise.catch((err) => {\n if (!err.message && typeof err.inspect === \"function\") {\n // AssertionFailedError doesn't set message attribute\n err.message = err.inspect();\n }\n if (err instanceof Error || err.constructor.name === \"Error\") {\n this.runtime.updateStep(currentStep, (step) => {\n step.status = getStatusFromError(err as Error);\n step.statusDetails = { ...step.statusDetails, ...getMessageAndTraceFromError(err as Error) };\n });\n }\n return Promise.reject(err);\n });\n }\n\n this.runtime.updateStep(currentStep, updateFunc);\n this.runtime.stopStep(currentStep);\n }\n\n protected getFrameworkName = () => \"codeceptjs\";\n\n protected getWorkerId = () => undefined;\n}\n"],"mappings":";;;;;AAAA,SAASA,KAAK,EAAEC,QAAQ,QAAQ,YAAY;AAE5C,SAASC,GAAG,QAAQ,cAAc;AAClC,SAASC,SAAS,EAAEC,KAAK,EAAEC,MAAM,QAAyB,mBAAmB;AAC7E,SAASC,2BAA2B,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ,uBAAuB;AACtG,OAAOC,mBAAmB,MAAM,cAAc;AAG9C,OAAO,MAAMC,wBAAwB,SAASD,mBAAmB,CAAC;EAChEE,WAAWA,CAACC,MAAoB,EAAEC,IAAwB,EAAEC,UAAmB,EAAE;IAC/E,KAAK,CAACF,MAAM,EAAEC,IAAI,EAAEC,UAAU,CAAC;IAACC,eAAA,2BAmGL,MAAM,YAAY;IAAAA,eAAA,sBAEvB,MAAMC,SAAS;IApGrC,IAAI,CAACC,cAAc,CAAC,CAAC;EACvB;EAEAA,cAAcA,CAAA,EAAG;IACf;IACAjB,KAAK,CAACkB,UAAU,CAACC,EAAE,CAACnB,KAAK,CAACoB,IAAI,CAACC,MAAM,EAAE,IAAI,CAACC,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnE;IACAvB,KAAK,CAACkB,UAAU,CAACC,EAAE,CAACnB,KAAK,CAACwB,IAAI,CAACC,OAAO,EAAE,IAAI,CAACC,WAAW,CAACH,IAAI,CAAC,IAAI,CAAC,CAAC;IACpEvB,KAAK,CAACkB,UAAU,CAACC,EAA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,WAAW,CAAC;EACpC;AAKF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"reporter.js","names":["event","recorder","env","LabelName","Stage","Status","getMessageAndTraceFromError","getStatusFromError","isMetadataTag","stripAnsi","AllureMochaReporter","MAX_META_STEP_NESTING","AllureCodeceptJsReporter","constructor","runner","opts","isInWorker","_defineProperty","undefined","registerEvents","dispatcher","on","test","before","testStarted","bind","failed","testFailed","finished","testFinished","step","started","stepStarted","passed","stepPassed","stepFailed","comment","stepComment","bddStep","bddStepStarted","after","currentTest","tags","extraTagLabels","filter","tag","map","startsWith","substring","trim","length","name","TAG","value","runtime","updateTest","tr","labels","push","_","error","status","message","statusDetails","currentBddStep","stopCurrentStep","result","stage","FINISHED","BROKEN","_objectSpread","id","metaStepStack","updateStep","stopStep","PASSED","_this$currentHook","root","currentHook","stepPath","current","metaStep","isBDD","_current$toString","toString","index","Math","min","i","startStep","_this$currentHook2","keyword","text","TRY_TO","FAILED","updateFunc","_this$currentHook3","currentStep","stopStepById","promise","catch","err","inspect","Error","Promise","reject"],"sources":["../../src/reporter.ts"],"sourcesContent":["import { event, recorder } from \"codeceptjs\";\nimport type * as Mocha from \"mocha\";\nimport { env } from \"node:process\";\nimport { LabelName, Stage, Status, type StepResult } from \"allure-js-commons\";\nimport { getMessageAndTraceFromError, getStatusFromError, isMetadataTag, stripAnsi } from \"allure-js-commons/sdk\";\nimport AllureMochaReporter from \"allure-mocha\";\nimport type { CodeceptBddStep, CodeceptError, CodeceptStep } from \"./model.js\";\n\ninterface MetaStep {\n name: string;\n id: string;\n}\n\nconst MAX_META_STEP_NESTING = 10;\n\nexport class AllureCodeceptJsReporter extends AllureMochaReporter {\n protected currentBddStep?: string;\n protected metaStepStack: MetaStep[] = [];\n\n constructor(runner: Mocha.Runner, opts: Mocha.MochaOptions, isInWorker: boolean) {\n super(runner, opts, isInWorker);\n this.registerEvents();\n }\n\n registerEvents() {\n // Test\n event.dispatcher.on(event.test.before, this.testStarted.bind(this));\n event.dispatcher.on(event.test.failed, this.testFailed.bind(this));\n event.dispatcher.on(event.test.finished, this.testFinished.bind(this));\n // Step\n event.dispatcher.on(event.step.started, this.stepStarted.bind(this));\n event.dispatcher.on(event.step.passed, this.stepPassed.bind(this));\n event.dispatcher.on(event.step.failed, this.stepFailed.bind(this));\n event.dispatcher.on(event.step.comment, this.stepComment.bind(this));\n\n event.dispatcher.on(event.bddStep.before, this.bddStepStarted.bind(this));\n event.dispatcher.on(event.bddStep.after, this.stepPassed.bind(this));\n }\n\n testStarted(test: { tags?: string[] }) {\n if (!this.currentTest) {\n return;\n }\n\n const tags = test.tags || [];\n const extraTagLabels = tags\n .filter((tag) => tag && !isMetadataTag(tag))\n .map((tag) => (tag.startsWith(\"@\") ? tag.substring(1) : tag))\n .map((tag) => tag.trim())\n .filter((tag) => tag.length > 0)\n .map((tag) => ({ name: LabelName.TAG, value: tag }));\n\n this.runtime.updateTest(this.currentTest, (tr) => {\n tr.labels.push(...extraTagLabels);\n });\n }\n\n testFailed(_: {}, error: Error) {\n const status = getStatusFromError({ message: error.message } as Error);\n const statusDetails = getMessageAndTraceFromError(error);\n if (this.currentBddStep) {\n this.stopCurrentStep((result) => {\n result.stage = Stage.FINISHED;\n result.status = Status.BROKEN;\n if (error) {\n result.status = status;\n result.statusDetails = { ...statusDetails };\n }\n });\n }\n this.currentBddStep = undefined;\n\n for (const { id } of this.metaStepStack) {\n this.runtime.updateStep(id, (result) => {\n result.stage = Stage.FINISHED;\n result.status = Status.BROKEN;\n if (error) {\n result.status = status;\n result.statusDetails = { ...statusDetails };\n }\n });\n this.runtime.stopStep(id);\n }\n this.metaStepStack = [];\n }\n\n testFinished() {\n if (this.currentBddStep) {\n this.runtime.updateStep(this.currentBddStep, (result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n this.runtime.stopStep(this.currentBddStep);\n }\n this.currentBddStep = undefined;\n\n for (const { id } of this.metaStepStack) {\n this.runtime.updateStep(id, (result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n this.runtime.stopStep(id);\n }\n\n this.metaStepStack = [];\n }\n\n stepStarted(step: CodeceptStep) {\n const root = this.currentHook ?? this.currentTest;\n if (!root) {\n return;\n }\n\n const stepPath: string[] = [];\n let current = step.metaStep;\n while (current && !current.isBDD() && stepPath.length < MAX_META_STEP_NESTING) {\n stepPath.push(stripAnsi(current.toString() ?? \"\").trim());\n current = current.metaStep;\n }\n\n let index = 0;\n while (\n index < Math.min(this.metaStepStack.length, stepPath.length) &&\n this.metaStepStack[index].name === stepPath[index]\n ) {\n index++;\n }\n\n for (let i = index; i < this.metaStepStack.length; i++) {\n const id = this.metaStepStack[i].id;\n this.runtime.updateStep(id, (result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n this.runtime.stopStep(id);\n }\n\n for (let i = index; i < stepPath.length; i++) {\n const name = stepPath[i];\n const id = this.runtime.startStep(root, undefined, {\n name,\n });\n if (id) {\n this.metaStepStack.push({ name, id });\n }\n }\n\n this.runtime.startStep(root, undefined, {\n name: step.toString().trim(),\n });\n }\n\n bddStepStarted(step: CodeceptBddStep) {\n const root = this.currentHook ?? this.currentTest;\n if (!root) {\n return;\n }\n this.currentBddStep = this.runtime.startStep(root, undefined, {\n name: step.keyword + step.text,\n });\n }\n\n // according to the docs, codeceptjs supposed to report the error,\n // but actually it's never reported\n stepFailed(_: CodeceptJS.Step, error?: CodeceptError) {\n this.stopCurrentStep((result) => {\n result.stage = Stage.FINISHED;\n if (error) {\n result.status = getStatusFromError({ message: error.message } as Error);\n result.statusDetails = getMessageAndTraceFromError(error);\n } else {\n result.status = env.TRY_TO === \"true\" ? Status.BROKEN : Status.FAILED;\n }\n });\n }\n\n stepComment() {\n this.stopCurrentStep((result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n }\n\n stepPassed() {\n this.stopCurrentStep((result) => {\n result.status = Status.PASSED;\n result.stage = Stage.FINISHED;\n });\n }\n\n stopCurrentStep(updateFunc: (result: StepResult) => void) {\n const root = this.currentHook ?? this.currentTest;\n const currentStep = root ? this.runtime.currentStep(root) : undefined;\n\n this.stopStepById(currentStep, updateFunc);\n }\n\n stopStepById(currentStep: string | undefined, updateFunc: (result: StepResult) => void) {\n if (!currentStep) {\n return;\n }\n const promise = recorder.promise();\n // @ts-ignore\n if (promise) {\n promise.catch((err) => {\n if (!err.message && typeof err.inspect === \"function\") {\n // AssertionFailedError doesn't set message attribute\n err.message = err.inspect();\n }\n if (err instanceof Error || err.constructor.name === \"Error\") {\n this.runtime.updateStep(currentStep, (step) => {\n step.status = getStatusFromError(err as Error);\n step.statusDetails = { ...step.statusDetails, ...getMessageAndTraceFromError(err as Error) };\n });\n }\n return Promise.reject(err);\n });\n }\n\n this.runtime.updateStep(currentStep, updateFunc);\n this.runtime.stopStep(currentStep);\n }\n\n protected getFrameworkName = () => \"codeceptjs\";\n\n protected getWorkerId = () => undefined;\n}\n"],"mappings":";;;;;AAAA,SAASA,KAAK,EAAEC,QAAQ,QAAQ,YAAY;AAE5C,SAASC,GAAG,QAAQ,cAAc;AAClC,SAASC,SAAS,EAAEC,KAAK,EAAEC,MAAM,QAAyB,mBAAmB;AAC7E,SAASC,2BAA2B,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,SAAS,QAAQ,uBAAuB;AACjH,OAAOC,mBAAmB,MAAM,cAAc;AAQ9C,IAAMC,qBAAqB,GAAG,EAAE;AAEhC,OAAO,MAAMC,wBAAwB,SAASF,mBAAmB,CAAC;EAIhEG,WAAWA,CAACC,MAAoB,EAAEC,IAAwB,EAAEC,UAAmB,EAAE;IAC/E,KAAK,CAACF,MAAM,EAAEC,IAAI,EAAEC,UAAU,CAAC;IAACC,eAAA;IAAAA,eAAA,wBAHI,EAAE;IAAAA,eAAA,2BA8MX,MAAM,YAAY;IAAAA,eAAA,sBAEvB,MAAMC,SAAS;IA5MrC,IAAI,CAACC,cAAc,CAAC,CAAC;EACvB;EAEAA,cAAcA,CAAA,EAAG;IACf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AAGpB,IAAI,GAAG,IAAI,CAACvB,OAAO,CAAC2C,WAAW,CAACpB,IAAI,CAAC,GAAG3D,SAAS;IAErE,IAAI,CAACgF,YAAY,CAACD,WAAW,EAAEF,UAAU,CAAC;EAC5C;EAEAG,YAAYA,CAACD,WAA+B,EAAEF,UAAwC,EAAE;IACtF,IAAI,CAACE,WAAW,EAAE;MAChB;IACF;IACA,IAAME,OAAO,GAAGlG,QAAQ,CAACkG,OAAO,CAAC,CAAC;IAClC;IACA,IAAIA,OAAO,EAAE;MACXA,OAAO,CAACC,KAAK,CAAEC,GAAG,IAAK;QACrB,IAAI,CAACA,GAAG,CAACvC,OAAO,IAAI,OAAOuC,GAAG,CAACC,OAAO,KAAK,UAAU,EAAE;UACrD;UACAD,GAAG,CAACvC,OAAO,GAAGuC,GAAG,CAACC,OAAO,CAAC,CAAC;QAC7B;QACA,IAAID,GAAG,YAAYE,KAAK,IAAIF,GAAG,CAACxF,WAAW,CAACsC,IAAI,KAAK,OAAO,EAAE;UAC5D,IAAI,CAACG,OAAO,CAACmB,UAAU,CAACwB,WAAW,EAAGnE,IAAI,IAAK;YAC7CA,IAAI,CAAC+B,MAAM,GAAGtD,kBAAkB,CAAC8F,GAAY,CAAC;YAC9CvE,IAAI,CAACiC,aAAa,GAAAO,aAAA,CAAAA,aAAA,KAAQxC,IAAI,CAACiC,aAAa,GAAKzD,2BAA2B,CAAC+F,GAAY,CAAC,CAAE;UAC9F,CAAC,CAAC;QACJ;QACA,OAAOG,OAAO,CAACC,MAAM,CAACJ,GAAG,CAAC;MAC5B,CAAC,CAAC;IACJ;IAEA,IAAI,CAAC/C,OAAO,CAACmB,UAAU,CAACwB,WAAW,EAAEF,UAAU,CAAC;IAChD,IAAI,CAACzC,OAAO,CAACoB,QAAQ,CAACuB,WAAW,CAAC;EACpC;AAKF","ignoreList":[]}
|
package/dist/types/model.d.ts
CHANGED
|
@@ -19,4 +19,12 @@ export interface CodeceptStep {
|
|
|
19
19
|
status: string;
|
|
20
20
|
metaStep: CodeceptStep;
|
|
21
21
|
toString: () => string;
|
|
22
|
+
isBDD: () => boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface CodeceptBddStep {
|
|
25
|
+
id: string;
|
|
26
|
+
keyword: string;
|
|
27
|
+
keywordType: string;
|
|
28
|
+
text: string;
|
|
29
|
+
startTime: number;
|
|
22
30
|
}
|
package/dist/types/reporter.d.ts
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import type * as Mocha from "mocha";
|
|
2
2
|
import { type StepResult } from "allure-js-commons";
|
|
3
3
|
import AllureMochaReporter from "allure-mocha";
|
|
4
|
-
import type { CodeceptError, CodeceptStep } from "./model.js";
|
|
4
|
+
import type { CodeceptBddStep, CodeceptError, CodeceptStep } from "./model.js";
|
|
5
|
+
interface MetaStep {
|
|
6
|
+
name: string;
|
|
7
|
+
id: string;
|
|
8
|
+
}
|
|
5
9
|
export declare class AllureCodeceptJsReporter extends AllureMochaReporter {
|
|
10
|
+
protected currentBddStep?: string;
|
|
11
|
+
protected metaStepStack: MetaStep[];
|
|
6
12
|
constructor(runner: Mocha.Runner, opts: Mocha.MochaOptions, isInWorker: boolean);
|
|
7
13
|
registerEvents(): void;
|
|
8
14
|
testStarted(test: {
|
|
9
15
|
tags?: string[];
|
|
10
16
|
}): void;
|
|
17
|
+
testFailed(_: {}, error: Error): void;
|
|
18
|
+
testFinished(): void;
|
|
11
19
|
stepStarted(step: CodeceptStep): void;
|
|
20
|
+
bddStepStarted(step: CodeceptBddStep): void;
|
|
12
21
|
stepFailed(_: CodeceptJS.Step, error?: CodeceptError): void;
|
|
13
22
|
stepComment(): void;
|
|
14
23
|
stepPassed(): void;
|
|
15
24
|
stopCurrentStep(updateFunc: (result: StepResult) => void): void;
|
|
25
|
+
stopStepById(currentStep: string | undefined, updateFunc: (result: StepResult) => void): void;
|
|
16
26
|
protected getFrameworkName: () => string;
|
|
17
27
|
protected getWorkerId: () => undefined;
|
|
18
28
|
}
|
|
29
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "allure-codeceptjs",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Allure codeceptjs integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"test": "vitest run"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"allure-js-commons": "3.0
|
|
50
|
-
"allure-mocha": "3.0
|
|
49
|
+
"allure-js-commons": "3.2.0",
|
|
50
|
+
"allure-mocha": "3.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@babel/cli": "^7.24.6",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
67
67
|
"@typescript-eslint/parser": "^8.0.0",
|
|
68
68
|
"allure-commandline": "^2.29.0",
|
|
69
|
-
"allure-vitest": "3.0
|
|
69
|
+
"allure-vitest": "3.2.0",
|
|
70
70
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
71
71
|
"codeceptjs": "^3.6.10",
|
|
72
72
|
"eslint": "^8.57.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"npm-run-all2": "^7.0.0",
|
|
80
80
|
"rimraf": "^6.0.0",
|
|
81
81
|
"typescript": "^5.2.2",
|
|
82
|
-
"vitest": "^
|
|
82
|
+
"vitest": "^3.0.5"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"codeceptjs": ">=2.3.6"
|