testit-adapter-cypress 4.0.5 → 4.1.1-TMS-5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/browser/lifecycle.js +3 -2
- package/dist/reporter.d.ts +1 -0
- package/dist/reporter.js +34 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,6 +12,10 @@ npm install testit-adapter-cypress
|
|
|
12
12
|
|
|
13
13
|
### Configuration
|
|
14
14
|
|
|
15
|
+
#### Log level
|
|
16
|
+
|
|
17
|
+
The adapter includes a custom logger; the default level is `warn`. Set another level at runtime with the `LOG_LEVEL` environment variable: `error`, `warn`, `info`, or `debug`.
|
|
18
|
+
|
|
15
19
|
| Description | File property | Environment variable |
|
|
16
20
|
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|--------------------------------------------|
|
|
17
21
|
| Location of the TMS instance | url | TMS_URL |
|
|
@@ -24,6 +28,7 @@ npm install testit-adapter-cypress
|
|
|
24
28
|
| It enables/disables certificate validation (**It's optional**). Default value - true | certValidation | TMS_CERT_VALIDATION |
|
|
25
29
|
| Mode of automatic creation test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest)<br/>false - in this mode, the adapter will not create a test case | automaticCreationTestCases | TMS_AUTOMATIC_CREATION_TEST_CASES |
|
|
26
30
|
| Mode of automatic updation links to test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will update links to test cases<br/>false - in this mode, the adapter will not update link to test cases | automaticUpdationLinksToTestCases | TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES |
|
|
31
|
+
| Logger level, default value is `warn`, available values: [`error`, `warn`, `info`, `debug`] | | LOG_LEVEL |
|
|
27
32
|
|
|
28
33
|
Add Adapter to Cypress file configuration:
|
|
29
34
|
|
|
@@ -7,6 +7,7 @@ const state_js_1 = require("./state.js");
|
|
|
7
7
|
const steps_js_1 = require("./steps.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
9
|
const status_js_1 = require("../models/status.js");
|
|
10
|
+
const testit_js_commons_1 = require("testit-js-commons");
|
|
10
11
|
const reportRunStart = () => {
|
|
11
12
|
(0, state_js_1.enqueueRuntimeMessage)({
|
|
12
13
|
type: "cypress_run_start",
|
|
@@ -219,9 +220,9 @@ const logTmsRootAfterError = (context, err) => {
|
|
|
219
220
|
// We play safe and swallow errors here to keep the original 'after all' error.
|
|
220
221
|
try {
|
|
221
222
|
// eslint-disable-next-line no-console
|
|
222
|
-
|
|
223
|
+
testit_js_commons_1.logger.error(`Unexpected error when reporting the failure of ${context.test?.title ?? "'after all'"}`);
|
|
223
224
|
// eslint-disable-next-line no-console
|
|
224
|
-
|
|
225
|
+
testit_js_commons_1.logger.error(err);
|
|
225
226
|
}
|
|
226
227
|
catch { }
|
|
227
228
|
};
|
package/dist/reporter.d.ts
CHANGED
package/dist/reporter.js
CHANGED
|
@@ -37,7 +37,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
37
37
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
38
38
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
39
39
|
};
|
|
40
|
-
var _TmsCypress_endAllSpecs, _TmsCypress_applySpecMessages, _TmsCypress_startRun, _TmsCypress_startSuite, _TmsCypress_stopSuite, _TmsCypress_startHook, _TmsCypress_stopHook, _TmsCypress_startTest, _TmsCypress_passTest, _TmsCypress_failTest, _TmsCypress_skipTest, _TmsCypress_addSkippedTest, _TmsCypress_stopTest, _TmsCypress_startStep, _TmsCypress_stopStep, _TmsCypress_finalizeStep, _TmsCypress_handleAttachmentPath, _TmsCypress_handleAttachmentContent, _TmsCypress_applyRuntimeMessage;
|
|
40
|
+
var _TmsCypress_endAllSpecs, _TmsCypress_applySpecMessages, _TmsCypress_startRun, _TmsCypress_startSuite, _TmsCypress_stopSuite, _TmsCypress_startHook, _TmsCypress_stopHook, _TmsCypress_startTest, _TmsCypress_passTest, _TmsCypress_failTest, _TmsCypress_skipTest, _TmsCypress_addSkippedTest, _TmsCypress_stopTest, _TmsCypress_sendTestResult, _TmsCypress_startStep, _TmsCypress_stopStep, _TmsCypress_finalizeStep, _TmsCypress_handleAttachmentPath, _TmsCypress_handleAttachmentContent, _TmsCypress_applyRuntimeMessage;
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.tmsCypress = exports.TmsCypress = void 0;
|
|
43
43
|
const fs = __importStar(require("fs"));
|
|
@@ -109,6 +109,10 @@ class TmsCypress {
|
|
|
109
109
|
const context = this.specContextByAbsolutePath.get(specAbsolutePath);
|
|
110
110
|
if (!context)
|
|
111
111
|
return;
|
|
112
|
+
if (this.importRealtime) {
|
|
113
|
+
this.specContextByAbsolutePath.delete(specAbsolutePath);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
112
116
|
let videoAttachmentIds = [];
|
|
113
117
|
if ((!this.videoOnFailOnly || context.failed) && cypressVideoPath) {
|
|
114
118
|
try {
|
|
@@ -175,10 +179,10 @@ class TmsCypress {
|
|
|
175
179
|
__classPrivateFieldGet(this, _TmsCypress_skipTest, "f").call(this, context, message.data);
|
|
176
180
|
break;
|
|
177
181
|
case "cypress_skipped_test":
|
|
178
|
-
__classPrivateFieldGet(this, _TmsCypress_addSkippedTest, "f").call(this, context, message.data);
|
|
182
|
+
await __classPrivateFieldGet(this, _TmsCypress_addSkippedTest, "f").call(this, context, message.data);
|
|
179
183
|
break;
|
|
180
184
|
case "cypress_test_end":
|
|
181
|
-
__classPrivateFieldGet(this, _TmsCypress_stopTest, "f").call(this, context, message.data);
|
|
185
|
+
await __classPrivateFieldGet(this, _TmsCypress_stopTest, "f").call(this, context, message.data);
|
|
182
186
|
break;
|
|
183
187
|
case "cypress_step_start":
|
|
184
188
|
__classPrivateFieldGet(this, _TmsCypress_startStep, "f").call(this, context, message.data);
|
|
@@ -265,7 +269,7 @@ class TmsCypress {
|
|
|
265
269
|
context.currentTestData.statusDetails = data.statusDetails;
|
|
266
270
|
}
|
|
267
271
|
});
|
|
268
|
-
_TmsCypress_addSkippedTest.set(this, (context, data) => {
|
|
272
|
+
_TmsCypress_addSkippedTest.set(this, async (context, data) => {
|
|
269
273
|
const alreadyAdded = context.completedTests.some((c) => c.fullNameSuffix === data.fullNameSuffix) ||
|
|
270
274
|
(context.currentTestData?.fullNameSuffix === data.fullNameSuffix);
|
|
271
275
|
if (alreadyAdded)
|
|
@@ -284,9 +288,13 @@ class TmsCypress {
|
|
|
284
288
|
attachmentIds: [],
|
|
285
289
|
externalKey: data.fullNameSuffix,
|
|
286
290
|
};
|
|
291
|
+
if (this.importRealtime) {
|
|
292
|
+
await __classPrivateFieldGet(this, _TmsCypress_sendTestResult, "f").call(this, context.specPath, t);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
287
295
|
context.completedTests.push(t);
|
|
288
296
|
});
|
|
289
|
-
_TmsCypress_stopTest.set(this, (context, data) => {
|
|
297
|
+
_TmsCypress_stopTest.set(this, async (context, data) => {
|
|
290
298
|
var _a;
|
|
291
299
|
if (context.currentTestData) {
|
|
292
300
|
context.currentTestData.duration = data.duration;
|
|
@@ -294,12 +302,29 @@ class TmsCypress {
|
|
|
294
302
|
context.currentTestData.stop = context.currentTestData.start + data.duration;
|
|
295
303
|
}
|
|
296
304
|
(_a = context.currentTestData).outcome ?? (_a.outcome = status_js_1.Status.PASSED);
|
|
297
|
-
|
|
305
|
+
if (this.importRealtime) {
|
|
306
|
+
await __classPrivateFieldGet(this, _TmsCypress_sendTestResult, "f").call(this, context.specPath, context.currentTestData);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
context.completedTests.push(context.currentTestData);
|
|
310
|
+
}
|
|
298
311
|
context.currentTestData = null;
|
|
299
312
|
}
|
|
300
313
|
context.stepStack = [];
|
|
301
314
|
context.stepsByFrontEndId.clear();
|
|
302
315
|
});
|
|
316
|
+
_TmsCypress_sendTestResult.set(this, async (specPath, testData, extraAttachmentIds = []) => {
|
|
317
|
+
const posixSpecPath = specPath.replace(/\\/g, "/");
|
|
318
|
+
const autotest = (0, converter_js_1.toAutotestPost)(posixSpecPath, testData);
|
|
319
|
+
testit_js_commons_1.logger.debug("[cypress] sendTestResult", {
|
|
320
|
+
externalId: autotest.externalId,
|
|
321
|
+
outcome: testData.outcome,
|
|
322
|
+
steps: testData.steps?.length ?? 0,
|
|
323
|
+
});
|
|
324
|
+
await this.strategy.loadAutotest(autotest, testData.outcome);
|
|
325
|
+
const result = (0, converter_js_1.toAutotestResult)(autotest.externalId, testData, testData.outcome, extraAttachmentIds);
|
|
326
|
+
await this.strategy.loadTestRun([result]);
|
|
327
|
+
});
|
|
303
328
|
_TmsCypress_startStep.set(this, (context, data) => {
|
|
304
329
|
const step = {
|
|
305
330
|
id: data.id,
|
|
@@ -422,12 +447,14 @@ class TmsCypress {
|
|
|
422
447
|
this.videoOnFailOnly = videoOnFailOnly;
|
|
423
448
|
const adapterConfig = rest.tmsOptions ?? rest;
|
|
424
449
|
const composed = new testit_js_commons_1.ConfigComposer().compose(adapterConfig);
|
|
450
|
+
this.importRealtime = Boolean(composed.importRealtime);
|
|
425
451
|
this.strategy = testit_js_commons_1.StrategyFactory.create(composed);
|
|
426
452
|
this.additions = new testit_js_commons_1.Additions(composed);
|
|
453
|
+
testit_js_commons_1.logger.debug("[cypress] reporter init", { importRealtime: this.importRealtime });
|
|
427
454
|
}
|
|
428
455
|
}
|
|
429
456
|
exports.TmsCypress = TmsCypress;
|
|
430
|
-
_TmsCypress_endAllSpecs = new WeakMap(), _TmsCypress_applySpecMessages = new WeakMap(), _TmsCypress_startRun = new WeakMap(), _TmsCypress_startSuite = new WeakMap(), _TmsCypress_stopSuite = new WeakMap(), _TmsCypress_startHook = new WeakMap(), _TmsCypress_stopHook = new WeakMap(), _TmsCypress_startTest = new WeakMap(), _TmsCypress_passTest = new WeakMap(), _TmsCypress_failTest = new WeakMap(), _TmsCypress_skipTest = new WeakMap(), _TmsCypress_addSkippedTest = new WeakMap(), _TmsCypress_stopTest = new WeakMap(), _TmsCypress_startStep = new WeakMap(), _TmsCypress_stopStep = new WeakMap(), _TmsCypress_finalizeStep = new WeakMap(), _TmsCypress_handleAttachmentPath = new WeakMap(), _TmsCypress_handleAttachmentContent = new WeakMap(), _TmsCypress_applyRuntimeMessage = new WeakMap();
|
|
457
|
+
_TmsCypress_endAllSpecs = new WeakMap(), _TmsCypress_applySpecMessages = new WeakMap(), _TmsCypress_startRun = new WeakMap(), _TmsCypress_startSuite = new WeakMap(), _TmsCypress_stopSuite = new WeakMap(), _TmsCypress_startHook = new WeakMap(), _TmsCypress_stopHook = new WeakMap(), _TmsCypress_startTest = new WeakMap(), _TmsCypress_passTest = new WeakMap(), _TmsCypress_failTest = new WeakMap(), _TmsCypress_skipTest = new WeakMap(), _TmsCypress_addSkippedTest = new WeakMap(), _TmsCypress_stopTest = new WeakMap(), _TmsCypress_sendTestResult = new WeakMap(), _TmsCypress_startStep = new WeakMap(), _TmsCypress_stopStep = new WeakMap(), _TmsCypress_finalizeStep = new WeakMap(), _TmsCypress_handleAttachmentPath = new WeakMap(), _TmsCypress_handleAttachmentContent = new WeakMap(), _TmsCypress_applyRuntimeMessage = new WeakMap();
|
|
431
458
|
const getRuntimeConfigDefaults = (config = {}) => ({
|
|
432
459
|
stepsFromCommands: {
|
|
433
460
|
maxArgumentLength: config.stepsFromCommands?.maxArgumentLength ?? utils_js_1.DEFAULT_RUNTIME_CONFIG.stepsFromCommands.maxArgumentLength,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-adapter-cypress",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1-TMS-5.7",
|
|
4
4
|
"description": "Cypress adapter for Test IT",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/node": "^20.14.2"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"testit-js-commons": "4.
|
|
45
|
+
"testit-js-commons": "4.1.1-TMS-5.7"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"dist"
|