testit-adapter-cypress 3.7.9 → 4.0.0-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/dist/browser/utils.js +28 -5
- package/dist/reporter.js +81 -8
- package/package.json +2 -2
package/dist/browser/utils.js
CHANGED
|
@@ -16,13 +16,36 @@ const resolveSpecRelativePath = (spec) => {
|
|
|
16
16
|
};
|
|
17
17
|
exports.resolveSpecRelativePath = resolveSpecRelativePath;
|
|
18
18
|
const uint8ArrayToBase64 = (data) => {
|
|
19
|
-
|
|
20
|
-
const u8arrayLike = Array.isArray(data) || data.buffer;
|
|
21
|
-
if (!u8arrayLike) {
|
|
19
|
+
if (typeof data === "string") {
|
|
22
20
|
return data;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let u8;
|
|
23
|
+
if (data instanceof Uint8Array) {
|
|
24
|
+
u8 = data;
|
|
25
|
+
}
|
|
26
|
+
else if (Array.isArray(data)) {
|
|
27
|
+
u8 = new Uint8Array(data);
|
|
28
|
+
}
|
|
29
|
+
else if (data && typeof data === "object" && ArrayBuffer.isView(data)) {
|
|
30
|
+
const v = data;
|
|
31
|
+
u8 = new Uint8Array(v.buffer, v.byteOffset, v.byteLength);
|
|
32
|
+
}
|
|
33
|
+
if (!u8?.length) {
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
const B = typeof globalThis.Buffer !== "undefined"
|
|
37
|
+
? globalThis.Buffer
|
|
38
|
+
: undefined;
|
|
39
|
+
if (B?.from) {
|
|
40
|
+
return B.from(u8).toString("base64");
|
|
41
|
+
}
|
|
42
|
+
// Browser: avoid String.fromCharCode.apply on huge arrays (argument limit / silent corruption).
|
|
43
|
+
const chunk = 0x8000;
|
|
44
|
+
let binary = "";
|
|
45
|
+
for (let i = 0; i < u8.length; i += chunk) {
|
|
46
|
+
binary += String.fromCharCode.apply(null, u8.subarray(i, i + chunk));
|
|
47
|
+
}
|
|
48
|
+
return btoa(binary);
|
|
26
49
|
};
|
|
27
50
|
exports.uint8ArrayToBase64 = uint8ArrayToBase64;
|
|
28
51
|
const getTestStartData = (test) => ({
|
package/dist/reporter.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
36
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
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");
|
|
@@ -7,11 +40,41 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
7
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;
|
|
8
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
42
|
exports.tmsCypress = exports.TmsCypress = void 0;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
10
45
|
const testit_js_commons_1 = require("testit-js-commons");
|
|
11
46
|
const converter_js_1 = require("./converter.js");
|
|
12
47
|
const utils_js_1 = require("./utils.js");
|
|
13
48
|
const node_utils_js_1 = require("./node-utils.js");
|
|
14
49
|
const status_js_1 = require("./models/status.js");
|
|
50
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
51
|
+
/** Wait until file size is stable (Cypress may still be finalizing e.g. MP4). */
|
|
52
|
+
async function readBinaryFileWhenStable(filePath, timeoutMs = 15000, stableMs = 300) {
|
|
53
|
+
const deadline = Date.now() + timeoutMs;
|
|
54
|
+
let lastSize = -1;
|
|
55
|
+
let stableSince = 0;
|
|
56
|
+
while (Date.now() < deadline) {
|
|
57
|
+
try {
|
|
58
|
+
const st = fs.statSync(filePath);
|
|
59
|
+
if (st.size > 0) {
|
|
60
|
+
if (st.size === lastSize) {
|
|
61
|
+
if (Date.now() - stableSince >= stableMs) {
|
|
62
|
+
return fs.readFileSync(filePath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
lastSize = st.size;
|
|
67
|
+
stableSince = Date.now();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// file may not exist yet
|
|
73
|
+
}
|
|
74
|
+
await sleep(80);
|
|
75
|
+
}
|
|
76
|
+
return fs.readFileSync(filePath);
|
|
77
|
+
}
|
|
15
78
|
class TmsCypress {
|
|
16
79
|
constructor(config = {}) {
|
|
17
80
|
this.specContextByAbsolutePath = new Map();
|
|
@@ -49,7 +112,9 @@ class TmsCypress {
|
|
|
49
112
|
let videoAttachmentIds = [];
|
|
50
113
|
if ((!this.videoOnFailOnly || context.failed) && cypressVideoPath) {
|
|
51
114
|
try {
|
|
52
|
-
const
|
|
115
|
+
const videoBuf = await readBinaryFileWhenStable(cypressVideoPath);
|
|
116
|
+
const videoName = path.basename(cypressVideoPath) || "recording.mp4";
|
|
117
|
+
const attachments = await this.additions.addAttachments(videoBuf, videoName);
|
|
53
118
|
videoAttachmentIds = attachments.map((a) => a.id);
|
|
54
119
|
}
|
|
55
120
|
catch {
|
|
@@ -276,25 +341,33 @@ class TmsCypress {
|
|
|
276
341
|
context.stepsByFrontEndId.delete(data.id);
|
|
277
342
|
});
|
|
278
343
|
_TmsCypress_handleAttachmentPath.set(this, async (context, data) => {
|
|
344
|
+
const target = (0, utils_js_1.last)(context.stepStack) ?? context.currentTestData;
|
|
345
|
+
if (!target) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
279
348
|
try {
|
|
280
|
-
const
|
|
349
|
+
const isVideoPath = /\.(mp4|webm|mkv)$/i.test(data.path);
|
|
350
|
+
const content = isVideoPath
|
|
351
|
+
? await readBinaryFileWhenStable(data.path)
|
|
352
|
+
: fs.readFileSync(data.path);
|
|
353
|
+
const attachments = await this.additions.addAttachments(content, data.name);
|
|
281
354
|
const ids = attachments.map((a) => a.id);
|
|
282
|
-
|
|
283
|
-
if (target)
|
|
284
|
-
target.attachmentIds.push(...ids);
|
|
355
|
+
target.attachmentIds.push(...ids);
|
|
285
356
|
}
|
|
286
357
|
catch {
|
|
287
358
|
// ignore
|
|
288
359
|
}
|
|
289
360
|
});
|
|
290
361
|
_TmsCypress_handleAttachmentContent.set(this, async (context, data) => {
|
|
362
|
+
const target = (0, utils_js_1.last)(context.stepStack) ?? context.currentTestData;
|
|
363
|
+
if (!target) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
291
366
|
try {
|
|
292
367
|
const buffer = Buffer.from(data.content, data.encoding);
|
|
293
368
|
const attachments = await this.additions.addAttachments(buffer, data.name);
|
|
294
369
|
const ids = attachments.map((a) => a.id);
|
|
295
|
-
|
|
296
|
-
if (target)
|
|
297
|
-
target.attachmentIds.push(...ids);
|
|
370
|
+
target.attachmentIds.push(...ids);
|
|
298
371
|
}
|
|
299
372
|
catch {
|
|
300
373
|
// ignore
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-adapter-cypress",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-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": "
|
|
45
|
+
"testit-js-commons": "4.0.0-TMS-5.7"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"dist"
|