@appsurify-testmap/rrweb-cypress-plugin 2.1.1-alpha.7 → 2.1.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +63 -0
- package/dist/index.js +107 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -29
- package/dist/index.mjs.map +1 -1
- package/dist/reporter.d.ts +1 -7
- package/dist/reporter.js +1 -1
- package/dist/reporter.js.map +1 -1
- package/dist/reporter.mjs +1 -1
- package/dist/reporter.mjs.map +1 -1
- package/package.json +6 -7
package/Readme.md
CHANGED
|
@@ -1,2 +1,65 @@
|
|
|
1
1
|
# @appsurify-testmap/rrweb-cypress-plugin
|
|
2
2
|
|
|
3
|
+
## Notes
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
// file: cypress.config.ts
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
fixturesFolder: false,
|
|
10
|
+
env: {
|
|
11
|
+
testmap: {
|
|
12
|
+
recordingOpts: {
|
|
13
|
+
checkoutEveryNvm: 5,
|
|
14
|
+
// excludeAttribute: /data-(cy|test(id)?|cypress|highlight-el|cypress-el)/i,
|
|
15
|
+
maskInputOptions: { password: true },
|
|
16
|
+
sampling: {
|
|
17
|
+
mousemove: false,
|
|
18
|
+
mouseInteraction: {
|
|
19
|
+
MouseUp: false,
|
|
20
|
+
MouseDown: false,
|
|
21
|
+
Click: true,
|
|
22
|
+
ContextMenu: true,
|
|
23
|
+
DblClick: true,
|
|
24
|
+
Focus: true,
|
|
25
|
+
Blur: true,
|
|
26
|
+
TouchStart: false,
|
|
27
|
+
TouchEnd: false,
|
|
28
|
+
},
|
|
29
|
+
scroll: 100,
|
|
30
|
+
media: 100,
|
|
31
|
+
input: 'last',
|
|
32
|
+
canvas: 'all',
|
|
33
|
+
visibility: {
|
|
34
|
+
mode: 'debounce',
|
|
35
|
+
debounce: 100,
|
|
36
|
+
threshold: 0.5,
|
|
37
|
+
sensitivity: 0.05,
|
|
38
|
+
rafThrottle: 100
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
flushCustomEvent: 'after',
|
|
42
|
+
// recordAfter: 'DOMContentStabilized',
|
|
43
|
+
recordAfter: 'DOMContentLoaded',
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
e2e: {
|
|
48
|
+
setupNodeEvents(on, config) {
|
|
49
|
+
registerRRWebReportTasks(on, {...config, outputReportDir: 'test-results/cypress/ui'});
|
|
50
|
+
return config;
|
|
51
|
+
},
|
|
52
|
+
baseUrl: 'http://localhost:8888',
|
|
53
|
+
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
// file: support.js
|
|
61
|
+
const { initializeTestmap } = require('@appsurify-testmap/rrweb-cypress-plugin')
|
|
62
|
+
|
|
63
|
+
initializeTestmap()
|
|
64
|
+
|
|
65
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of A(t))!O.call(e,s)&&s!==r&&g(e,s,{get:()=>t[s],enumerable:!(n=N(t,s))||n.enumerable});return e};var D=e=>L(g({},"__esModule",{value:!0}),e);var le={};P(le,{initializeTestmap:()=>M});module.exports=D(le);var b=new Map;function v(e,t){b.set(e,t)}function l(e){return b.get(e)}function p(e){return e.filter(t=>typeof t=="object"&&t!==null&&"log"in t&&t.log===!1?!1:typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null)}function w(e){let t=e?.[0];if(!t)return null;let r=t.tagName.toLowerCase(),n=t.id?`#${t.id}`:"",s=Array.from(t.classList).map(o=>`.${o}`).join("");return`${r}${n}${s}`}function a(e){return e.titlePath().join(" > ")}function F(e){if(e)return{id:e.id,file:e.file,invocationDetails:k(e.invocationDetails),pending:e.pending,root:e.root,title:e.title,type:e.type}}function k(e){return{absoluteFile:e?.absoluteFile??"",column:e?.column??0,fileUrl:e?.fileUrl??"",function:e?.function??"",line:e?.line??0,originalFile:e?.originalFile??"",relativeFile:e?.relativeFile??""}}function S(e){return{runner:e.runner,spec:U(e.spec),browser:W(e.browser),test:z(e.test),recorderEvents:Array.isArray(e.recorderEvents)?e.recorderEvents:[]}}function U(e){return{name:e.name??"",absolute:e.absolute??"",relative:e.relative??"",specFilter:e.specFilter??"",specType:e.specType??"integration",baseName:e.baseName??"",fileExtension:e.fileExtension??"",fileName:e.fileName??"",id:e.id??""}}function W(e){return{name:e.name??"",version:e.version??"",displayName:e.displayName??"",family:e.family??"",majorVersion:e.majorVersion??"",channel:e.channel??"",path:e.path??""}}function z(e){return{suite:F(e.parent),file:e.file??"",duration:e.duration??0,id:e.id??"",invocationDetails:k(e.invocationDetails),pending:e.pending??!1,state:e.state??"unknown",sync:e.sync??!1,timedOut:e.timedOut??!1,title:e.title??"",titlePath:typeof e.titlePath=="function"?e.titlePath():[],fullTitle:typeof e.fullTitle=="function"?e.fullTitle():"",type:e.type??"test"}}var $=require("@appsurify-testmap/rrweb"),C=require("@appsurify-testmap/rrweb-plugin-sequential-id-record");var x=`(function (g, f) {
|
|
2
2
|
if ("object" == typeof exports && "object" == typeof module) {
|
|
3
3
|
module.exports = f();
|
|
4
4
|
} else if ("function" == typeof define && define.amd) {
|
|
@@ -871,10 +871,13 @@ function inspectInlineEventHandlers$1() {
|
|
|
871
871
|
});
|
|
872
872
|
});
|
|
873
873
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
874
|
+
try {
|
|
875
|
+
if (document.readyState === "complete" || document.readyState === "interactive") {
|
|
876
|
+
inspectInlineEventHandlers$1();
|
|
877
|
+
} else {
|
|
878
|
+
document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
|
|
879
|
+
}
|
|
880
|
+
} catch (error) {
|
|
878
881
|
}
|
|
879
882
|
let _id = 1;
|
|
880
883
|
const tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
@@ -5581,10 +5584,13 @@ function inspectInlineEventHandlers() {
|
|
|
5581
5584
|
});
|
|
5582
5585
|
});
|
|
5583
5586
|
}
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5587
|
+
try {
|
|
5588
|
+
if (document.readyState === "complete" || document.readyState === "interactive") {
|
|
5589
|
+
inspectInlineEventHandlers();
|
|
5590
|
+
} else {
|
|
5591
|
+
document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
|
|
5592
|
+
}
|
|
5593
|
+
} catch (error) {
|
|
5588
5594
|
}
|
|
5589
5595
|
function getDefaultExportFromCjs(x2) {
|
|
5590
5596
|
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
@@ -10859,6 +10865,8 @@ function initViewportResizeObserver({ viewportResizeCb }, { win }) {
|
|
|
10859
10865
|
}
|
|
10860
10866
|
const INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
|
|
10861
10867
|
const lastInputValueMap = /* @__PURE__ */ new WeakMap();
|
|
10868
|
+
const FINALIZING_KEYS = ["Enter", "Tab", "Escape", "ArrowDown", "ArrowUp", "Delete"];
|
|
10869
|
+
const lastKeyInputValueMap = /* @__PURE__ */ new WeakMap();
|
|
10862
10870
|
function initInputObserver({
|
|
10863
10871
|
inputCb,
|
|
10864
10872
|
doc,
|
|
@@ -10931,6 +10939,22 @@ function initInputObserver({
|
|
|
10931
10939
|
const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
|
|
10932
10940
|
const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
|
|
10933
10941
|
if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
|
|
10942
|
+
console.debug(
|
|
10943
|
+
\`[\${nowTimestamp()}] [rrweb:record/observer] \\u26D4 phantom input ignored\`,
|
|
10944
|
+
{
|
|
10945
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
|
|
10946
|
+
node: index.describeNode(el),
|
|
10947
|
+
tag: el.tagName,
|
|
10948
|
+
nodeType: el.nodeType,
|
|
10949
|
+
attribute: el.attributes,
|
|
10950
|
+
value: el.value,
|
|
10951
|
+
isLikelyPhantom,
|
|
10952
|
+
isRenderDrivenTextInput,
|
|
10953
|
+
isValueFromDefault,
|
|
10954
|
+
isPhantomCheckbox,
|
|
10955
|
+
isPhantomRadio
|
|
10956
|
+
}
|
|
10957
|
+
);
|
|
10934
10958
|
return;
|
|
10935
10959
|
}
|
|
10936
10960
|
if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
|
|
@@ -10945,6 +10969,62 @@ function initInputObserver({
|
|
|
10945
10969
|
const handlers = events.map(
|
|
10946
10970
|
(eventName) => on(eventName, callbackWrapper(eventHandler), doc)
|
|
10947
10971
|
);
|
|
10972
|
+
const keyboardHandler = (event) => {
|
|
10973
|
+
const target = getEventTarget(event);
|
|
10974
|
+
if (!target || !target.tagName)
|
|
10975
|
+
return;
|
|
10976
|
+
if (sampling.input === "all") {
|
|
10977
|
+
eventHandler(event);
|
|
10978
|
+
return;
|
|
10979
|
+
}
|
|
10980
|
+
const tag = target.tagName;
|
|
10981
|
+
const key = event.key;
|
|
10982
|
+
const isFinalizingKey = FINALIZING_KEYS.includes(key);
|
|
10983
|
+
const isTextarea = tag === "TEXTAREA";
|
|
10984
|
+
const isFocused = doc.activeElement === target;
|
|
10985
|
+
const valueNow = target.value;
|
|
10986
|
+
const valueBefore = lastKeyInputValueMap.get(target);
|
|
10987
|
+
lastKeyInputValueMap.set(target, valueNow);
|
|
10988
|
+
if (!isFocused) {
|
|
10989
|
+
eventHandler(event);
|
|
10990
|
+
return;
|
|
10991
|
+
}
|
|
10992
|
+
if (isFinalizingKey) {
|
|
10993
|
+
if (!isTextarea) {
|
|
10994
|
+
eventHandler(event);
|
|
10995
|
+
return;
|
|
10996
|
+
}
|
|
10997
|
+
let lastValue = valueBefore != null ? valueBefore : "";
|
|
10998
|
+
let unchangedCount = 0;
|
|
10999
|
+
const REQUIRED_STABLE_FRAMES = 2;
|
|
11000
|
+
const checkFinal = () => {
|
|
11001
|
+
const currentValue = target.value;
|
|
11002
|
+
const stillFocused = doc.activeElement === target;
|
|
11003
|
+
const changed = currentValue !== lastValue;
|
|
11004
|
+
if (!stillFocused) {
|
|
11005
|
+
eventHandler(event);
|
|
11006
|
+
return;
|
|
11007
|
+
}
|
|
11008
|
+
if (!changed) {
|
|
11009
|
+
unchangedCount++;
|
|
11010
|
+
if (unchangedCount >= REQUIRED_STABLE_FRAMES) {
|
|
11011
|
+
eventHandler(event);
|
|
11012
|
+
return;
|
|
11013
|
+
}
|
|
11014
|
+
} else {
|
|
11015
|
+
unchangedCount = 0;
|
|
11016
|
+
lastValue = currentValue;
|
|
11017
|
+
}
|
|
11018
|
+
requestAnimationFrame(checkFinal);
|
|
11019
|
+
};
|
|
11020
|
+
requestAnimationFrame(checkFinal);
|
|
11021
|
+
return;
|
|
11022
|
+
}
|
|
11023
|
+
};
|
|
11024
|
+
handlers.push(
|
|
11025
|
+
on("keydown", callbackWrapper(keyboardHandler), doc)
|
|
11026
|
+
// on('keypress', callbackWrapper(keyboardHandler), doc),
|
|
11027
|
+
);
|
|
10948
11028
|
const currentWindow = doc.defaultView;
|
|
10949
11029
|
if (!currentWindow) {
|
|
10950
11030
|
return () => {
|
|
@@ -12932,13 +13012,14 @@ class VisibilityManager {
|
|
|
12932
13012
|
cancelAnimationFrame(this.rafId);
|
|
12933
13013
|
}
|
|
12934
13014
|
}
|
|
13015
|
+
const version$1 = "2.1.2-alpha.2";
|
|
12935
13016
|
let wrappedEmit;
|
|
12936
13017
|
let takeFullSnapshot$1;
|
|
12937
13018
|
let canvasManager;
|
|
12938
13019
|
let visibilityManager;
|
|
12939
13020
|
let recording = false;
|
|
12940
13021
|
const customEventQueue = [];
|
|
12941
|
-
let flushCustomEventQueue;
|
|
13022
|
+
let flushCustomEventQueue$1;
|
|
12942
13023
|
function waitForDOMStabilization(win) {
|
|
12943
13024
|
const maxWaitMs = 5e3;
|
|
12944
13025
|
return new Promise((resolve2) => {
|
|
@@ -13303,7 +13384,7 @@ function record(options = {}) {
|
|
|
13303
13384
|
mirror.getId(document)
|
|
13304
13385
|
);
|
|
13305
13386
|
};
|
|
13306
|
-
flushCustomEventQueue = () => {
|
|
13387
|
+
flushCustomEventQueue$1 = () => {
|
|
13307
13388
|
for (const e2 of customEventQueue) {
|
|
13308
13389
|
wrappedEmit(e2);
|
|
13309
13390
|
}
|
|
@@ -13437,37 +13518,34 @@ function record(options = {}) {
|
|
|
13437
13518
|
});
|
|
13438
13519
|
const init = () => {
|
|
13439
13520
|
if (flushCustomEvent === "before") {
|
|
13440
|
-
flushCustomEventQueue();
|
|
13521
|
+
flushCustomEventQueue$1();
|
|
13441
13522
|
}
|
|
13442
13523
|
takeFullSnapshot$1();
|
|
13443
13524
|
handlers.push(observe(document));
|
|
13444
13525
|
recording = true;
|
|
13445
13526
|
if (flushCustomEvent === "after") {
|
|
13446
|
-
flushCustomEventQueue();
|
|
13527
|
+
flushCustomEventQueue$1();
|
|
13447
13528
|
}
|
|
13448
13529
|
};
|
|
13449
13530
|
const runInit = async () => {
|
|
13450
13531
|
if (flushCustomEvent === "before") {
|
|
13451
|
-
flushCustomEventQueue();
|
|
13532
|
+
flushCustomEventQueue$1();
|
|
13452
13533
|
}
|
|
13453
13534
|
if (recordAfter === "DOMContentStabilized") {
|
|
13454
|
-
console.
|
|
13535
|
+
console.debug(\`[\${nowTimestamp()}] [rrweb:record] \\u{1F7E2} Waiting for DOM stabilization...\`);
|
|
13455
13536
|
await waitForDOMStabilization(window);
|
|
13456
|
-
console.
|
|
13537
|
+
console.debug(\`[\${nowTimestamp()}] [rrweb:record] \\u2705 DOM stabilized, starting recording\`);
|
|
13457
13538
|
}
|
|
13539
|
+
console.debug(\`[\${nowTimestamp()}] [rrweb:record] \\u2705 Init dom and takeFullSnapshot \`);
|
|
13458
13540
|
takeFullSnapshot$1();
|
|
13459
13541
|
handlers.push(observe(document));
|
|
13460
13542
|
recording = true;
|
|
13461
13543
|
if (flushCustomEvent === "after") {
|
|
13462
|
-
flushCustomEventQueue();
|
|
13544
|
+
flushCustomEventQueue$1();
|
|
13463
13545
|
}
|
|
13464
13546
|
};
|
|
13465
13547
|
if (document.readyState === "interactive" || document.readyState === "complete") {
|
|
13466
|
-
|
|
13467
|
-
void runInit();
|
|
13468
|
-
} else {
|
|
13469
|
-
init();
|
|
13470
|
-
}
|
|
13548
|
+
init();
|
|
13471
13549
|
} else {
|
|
13472
13550
|
handlers.push(
|
|
13473
13551
|
on("DOMContentLoaded", () => {
|
|
@@ -13475,9 +13553,8 @@ function record(options = {}) {
|
|
|
13475
13553
|
type: EventType.DomContentLoaded,
|
|
13476
13554
|
data: {}
|
|
13477
13555
|
});
|
|
13478
|
-
if (recordAfter === "DOMContentLoaded"
|
|
13479
|
-
|
|
13480
|
-
}
|
|
13556
|
+
if (recordAfter === "DOMContentLoaded")
|
|
13557
|
+
init();
|
|
13481
13558
|
})
|
|
13482
13559
|
);
|
|
13483
13560
|
handlers.push(
|
|
@@ -13489,14 +13566,14 @@ function record(options = {}) {
|
|
|
13489
13566
|
data: {}
|
|
13490
13567
|
});
|
|
13491
13568
|
if (recordAfter === "load")
|
|
13492
|
-
|
|
13569
|
+
init();
|
|
13493
13570
|
},
|
|
13494
13571
|
window
|
|
13495
13572
|
)
|
|
13496
13573
|
);
|
|
13497
13574
|
}
|
|
13498
13575
|
return () => {
|
|
13499
|
-
flushCustomEventQueue();
|
|
13576
|
+
flushCustomEventQueue$1();
|
|
13500
13577
|
handlers.forEach((h) => h());
|
|
13501
13578
|
processedNodeManager.destroy();
|
|
13502
13579
|
recording = false;
|
|
@@ -13506,10 +13583,11 @@ function record(options = {}) {
|
|
|
13506
13583
|
console.warn(error);
|
|
13507
13584
|
}
|
|
13508
13585
|
}
|
|
13586
|
+
record.getVersion = () => version$1;
|
|
13509
13587
|
record.isRecording = () => recording;
|
|
13510
13588
|
record.flushCustomEventQueue = () => {
|
|
13511
13589
|
console.warn(\`[rrweb] CustomEvent flushing: \${customEventQueue.length} events\`);
|
|
13512
|
-
flushCustomEventQueue();
|
|
13590
|
+
flushCustomEventQueue$1();
|
|
13513
13591
|
};
|
|
13514
13592
|
record.addCustomEvent = (tag, payload) => {
|
|
13515
13593
|
const customEvent = {
|
|
@@ -13559,5 +13637,5 @@ if (typeof module.exports == "object" && typeof exports == "object") {
|
|
|
13559
13637
|
return module.exports;
|
|
13560
13638
|
}))
|
|
13561
13639
|
//# sourceMappingURL=rrweb-record.umd.cjs.map
|
|
13562
|
-
`;var h=class{recordFn=null;stopFn=null;targetWindow=null;context;eventCounter=0;events=[];pendingEvents=[];constructor(){this.context={pushEvent:
|
|
13640
|
+
`;var j={slimDOMOptions:"all",inlineStylesheet:!0,recordDOM:!0,recordCanvas:!0,collectFonts:!0,inlineImages:!0,maskInputOptions:{password:!0},sampling:{mousemove:!1,mouseInteraction:{MouseUp:!1,MouseDown:!1,Click:!0,ContextMenu:!0,DblClick:!0,Focus:!0,Blur:!0,TouchStart:!1,TouchEnd:!1},scroll:100,media:100,input:"last",canvas:"all",visibility:{mode:"debounce",debounce:50,threshold:.5,sensitivity:.05,rafThrottle:50}},flushCustomEvent:"after",recordAfter:"DOMContentLoaded",userTriggeredOnInput:!0};function I(e,t){let r={...e};for(let n in t){let s=t[n],o=e[n];s&&typeof s=="object"&&!Array.isArray(s)&&o&&typeof o=="object"&&!Array.isArray(o)?r[n]=I(o,s):s!==void 0&&(r[n]=s)}return r}var h=class{recordFn=null;stopFn=null;targetWindow=null;context;eventCounter=0;events=[];recordOptions;pendingEvents=[];recorderScriptVersion="unknown";recorderLibVersion=$.version;constructor(t){this.recordOptions=I(j,t??{}),this.context={pushEvent:r=>this.events.push(r)}}handleEmit(t){if(t.type===0||t.type===1)return;let r={...t};this.context.pushEvent(r)}inject(t){let r=t;if(this.targetWindow=t,r.rrweb){this.recordFn=r.rrweb.record??null;return}let n=t.document.createElement("script");n.type="text/javascript",n.innerHTML=x,t.document.head.appendChild(n);let s=t.rrweb;if(!s||!s.record){console.error(`[${Date.now()}] [recorder] Failed to load rrweb.record`);return}this.recordFn=s.record,this.recorderScriptVersion=this.recordFn.getVersion()}start(){if(!this.targetWindow||!this.recordFn){console.debug(`[${Date.now()}] [recorder] Not ready to start`);return}if(this.stopFn){console.debug(`[${Date.now()}] [recorder] Already recording`);return}this.stopFn=this.recordFn({emit:t=>this.handleEmit(t),plugins:[(0,C.getRecordSequentialIdPlugin)({key:"id",getId:()=>++this.eventCounter})],...this.recordOptions}),this.flush()}stop(){this.flush(),this.stopFn?.(),this.stopFn=null}reset(){this.eventCounter=0,this.events=[],this.stop(),this.context={pushEvent:t=>this.events.push(t)}}flush(){if(!this.recordFn)return;let t=[];for(let r of this.pendingEvents)try{this.recordFn.addCustomEvent(r.tag,r.payload)}catch{console.debug(`[${Date.now()}] [recorder] flush failed for custom event: ${r.tag}`),t.push(r)}this.pendingEvents=t}addCustomEvent(t,r){let n={tag:t,payload:r};if(!this.recordFn||!this.stopFn){console.debug(`[${Date.now()}] [recorder] queued custom event (recorder not ready): ${t}`),this.pendingEvents.push(n);return}try{this.recordFn.addCustomEvent(t,r)}catch(s){console.debug(`[${Date.now()}] [recorder] error adding custom event: ${t}`,s),this.pendingEvents.push(n)}}isRecordingReady(){return!!this.recordFn&&!!this.stopFn}isRecording(){return this.recordFn?.isRecording()||!1}getScriptVersion(){return`@appsurify-testmap/rrweb-record:${this.recorderScriptVersion}`}getLibVersion(){return`@appsurify-testmap/rrweb:${this.recorderLibVersion}`}getEvents(){return this.events}getMirror(){return this.recordFn?.mirror}bind(t){this.context=t}setEventCounter(t){this.eventCounter=t}};var f=h;var y=Cypress.env("testmap")??{},V=typeof y=="object"&&"recordingOpts"in y?y.recordingOpts:f,i=new f(V),E=()=>{Cypress.on("test:before:run",H).on("log:added",G).on("log:changed",K).on("window:before:load",J).on("window:before:unload",Y).on("window:unload",Z).on("window:load",q).on("command:enqueued",Q).on("command:start",ee).on("command:end",te).on("command:retry",X).on("skipped:command:end",re).on("test:after:run",ie).on("command:failed",ne).on("command:queue:end",se).on("fail",oe),afterEach(()=>{let e=Cypress.currentTest;if(!e)return;let t=a({titlePath:()=>e.titlePath}),r=l(t);if(!r)return;r.recorderEvents.map(s=>{if(s.type!==5)return s;let o=r.commandLiveRefs.get(s.data.payload.id);return s.data.payload.state=o?.state??"unknown",s.data.payload.args=p(o?.get("args")),s.data.payload.query=o?.get("query"),s.data.payload.timeout=o?.get("timeout"),s.data.payload.name=o?.get("name"),s.data.payload.type=o?.get("type"),o?.get("prev")&&(s.data.payload.prev={state:o?.get("prev").state,name:o?.get("prev").get("name"),args:p(o?.get("prev").get("args")),type:o?.get("prev").get("type"),query:o?.get("prev").get("query"),id:o?.get("prev").get("id")}),o?.get("next")&&(s.data.payload.next={state:o?.get("next").state,name:o?.get("next").get("name"),args:p(o?.get("next").get("args")),type:o?.get("next").get("type"),query:o?.get("next").get("query"),id:o?.get("next").get("id")}),s}),console.debug(`[${Date.now()}] [cypress] afterEach:`,r.recorderEvents);let n=S(r);try{cy.task("saveRRWebReport",{testRunResult:n},{log:!1})}catch(s){console.error(`[${Date.now()}] [cypress] afterEach:saveRRWebReport`,s)}})},H=(e,t)=>{let r=a(t),n={runner:{source:"cypress",type:Cypress.testingType,version:Cypress.version,platform:Cypress.platform,arch:Cypress.arch,recorder:{scriptVersion:i.getLibVersion()||"unknown",libVersion:i.getLibVersion()||"unknown"}},spec:Cypress.spec,test:t,browser:Cypress.browser,autWindow:null,waitForPaint:()=>Promise.resolve(void 0),paintComplete:!1,recorderEvents:[],commandLiveRefs:new Map};v(r,n),i.bind({pushEvent:s=>{if(console.debug(`[${Date.now()}] [cypress] pushEvent`,s),n.recorderEvents.push(s),s.type===5){let u=n.commandLiveRefs.get(s.data.payload.id)?.get("subject"),m=u?.selector??w(u),d=i.getMirror()?.getMeta(u?.[0]);s.data.payload.element={...d,selector:m,childNodes:[]}}}})},G=(e,t)=>{},K=(e,t)=>{},Y=e=>{},Z=e=>{try{i.stop()}catch{}},J=e=>{i.inject(e);let t=Cypress.currentTest;if(!t)return;let r=a({titlePath:()=>t.titlePath}),n=l(r);n&&(n.runner.recorder.scriptVersion=i.getScriptVersion(),n.autWindow=e,n.paintComplete=!1)},q=e=>{console.debug(`[${Date.now()}] [cypress] onWindowLoad`,e);let t=Cypress.currentTest;if(!t)return;let r=a({titlePath:()=>t.titlePath}),n=l(r);n&&(n.autWindow||(n.autWindow=e,n.paintComplete=!1),n.waitForPaint=s=>new Promise(o=>{let m=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{o(s)})})},c=(()=>{let d=!1;return()=>{d||(d=!0,m())}})();["interactive","complete"].includes(e.document.readyState)?c():(e.addEventListener("DOMContentLoaded",c,{once:!0}),e.addEventListener("load",c,{once:!0}),setTimeout(()=>{console.warn("\u23F3 Timeout: forcing resolution"),c()},5e3))}),n.waitForPaint().then(async()=>{n.paintComplete=!0,i.inject(e),i.start()}))},Q=e=>{let t=Cypress.currentTest;if(!t)return;let r=a({titlePath:()=>t.titlePath}),n=l(r);n&&n.commandLiveRefs.set(e.id,e)},X=e=>{},ee=e=>{let t=Cypress.currentTest;if(!t)return;let r=a({titlePath:()=>t.titlePath}),n=l(r);n&&n.commandLiveRefs.set(e.attributes.id,e)},te=e=>{console.debug(`[${Date.now()}] [cypress] onCommandEnd`,e);let t=Cypress.currentTest;if(!t)return;let r=a({titlePath:()=>t.titlePath}),n=l(r);if(!n)return;(async()=>{!n.paintComplete&&typeof n.waitForPaint=="function"&&(await n.waitForPaint(),n.paintComplete=!0)})(),i.addCustomEvent(`${e.attributes.name}`,{id:e.attributes.id})},ne=(e,t)=>{console.debug(`[${Date.now()}] [cypress] onCommandFailed`,e),i.addCustomEvent(`${e.attributes.name}`,{id:e.attributes.id})},re=e=>{console.debug(`[${Date.now()}] [cypress] onSkippedCommandEnd`,e);let t=Cypress.currentTest;if(!t)return;let r=a({titlePath:()=>t.titlePath}),n=l(r);n&&(n.commandLiveRefs.set(e.attributes.id,e),i.addCustomEvent(`${e.attributes.name}`,{id:e.attributes.id}))},se=()=>{},oe=(e,t)=>{throw e},ie=async(e,t)=>{console.debug(`[${Date.now()}] [cypress] onTestAfterRun`,e,t),i.stop()};var _=()=>{Cypress.mocha.getRunner().on("hook",ae)},ae=()=>{},R=()=>{beforeEach("",()=>{}),afterEach("",()=>{})};var T=()=>{E(),_(),R()};var M=()=>{T()};0&&(module.exports={initializeTestmap});
|
|
13563
13641
|
//# sourceMappingURL=index.js.map
|