@testspectra/react-native 1.3.5 → 1.3.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/index.js +42 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -699,6 +699,26 @@ function getAssertionTimeoutMs() {
|
|
|
699
699
|
function emitEvent(tag, payload) {
|
|
700
700
|
console.log(`[${tag}] ${payload}`);
|
|
701
701
|
}
|
|
702
|
+
async function trackGroup(title, fn) {
|
|
703
|
+
const currentTest = globalThis.__CURRENT_TEST_TITLE__ || globalThis.__CURRENT_TEST_ID__ || "";
|
|
704
|
+
const workerId = globalThis.__TESTSPECTRA_WORKER_ID__;
|
|
705
|
+
const payload = { title, path: [...groupStack, title], depth: groupStack.length };
|
|
706
|
+
if (currentTest) payload.test = currentTest;
|
|
707
|
+
if (workerId !== void 0) payload.workerId = workerId;
|
|
708
|
+
emitEvent("TESTSPECTRA_GROUP_START", JSON.stringify(payload));
|
|
709
|
+
groupStack.push(title);
|
|
710
|
+
const start = Date.now();
|
|
711
|
+
try {
|
|
712
|
+
const result = await fn();
|
|
713
|
+
emitEvent("TESTSPECTRA_GROUP_PASS", `${JSON.stringify(payload)} (${Date.now() - start}ms)`);
|
|
714
|
+
return result;
|
|
715
|
+
} catch (err) {
|
|
716
|
+
emitEvent("TESTSPECTRA_GROUP_FAIL", `${JSON.stringify(payload)} (${Date.now() - start}ms)`);
|
|
717
|
+
throw err;
|
|
718
|
+
} finally {
|
|
719
|
+
groupStack.pop();
|
|
720
|
+
}
|
|
721
|
+
}
|
|
702
722
|
function describeTarget(target) {
|
|
703
723
|
if (target === void 0 || target === null) return "";
|
|
704
724
|
if (typeof target === "string") return target;
|
|
@@ -719,8 +739,17 @@ async function trackStep(category, payloadObj, fn) {
|
|
|
719
739
|
const workerId = globalThis.__TESTSPECTRA_WORKER_ID__;
|
|
720
740
|
if (currentTest && !payloadObj.test) payloadObj.test = currentTest;
|
|
721
741
|
if (workerId !== void 0 && payloadObj.workerId === void 0) payloadObj.workerId = workerId;
|
|
722
|
-
|
|
742
|
+
const group = groupStack[groupStack.length - 1];
|
|
743
|
+
stepContext = {
|
|
744
|
+
index: stepContext.index + 1,
|
|
745
|
+
label: `${payloadObj.key} ${describeTarget(payloadObj.target)}`.trim(),
|
|
746
|
+
group
|
|
747
|
+
};
|
|
723
748
|
payloadObj.step = stepContext.index;
|
|
749
|
+
if (group !== void 0) {
|
|
750
|
+
payloadObj.group = group;
|
|
751
|
+
payloadObj.groupPath = [...groupStack];
|
|
752
|
+
}
|
|
724
753
|
lastResolved = void 0;
|
|
725
754
|
emitEvent("TESTSPECTRA_STEP_START", JSON.stringify(payloadObj));
|
|
726
755
|
const start = Date.now();
|
|
@@ -766,13 +795,14 @@ async function pollCondition(fn, timeoutMs, intervalMs = 15) {
|
|
|
766
795
|
return false;
|
|
767
796
|
}
|
|
768
797
|
}
|
|
769
|
-
var activeDurationSink, stepContext, lastResolved;
|
|
798
|
+
var activeDurationSink, stepContext, groupStack, lastResolved;
|
|
770
799
|
var init_reporter = __esm({
|
|
771
800
|
"../../core/worker-runtime/src/harness/reporter.ts"() {
|
|
772
801
|
"use strict";
|
|
773
802
|
init_config();
|
|
774
803
|
activeDurationSink = null;
|
|
775
804
|
stepContext = { index: 0, label: "" };
|
|
805
|
+
groupStack = [];
|
|
776
806
|
}
|
|
777
807
|
});
|
|
778
808
|
|
|
@@ -1547,15 +1577,9 @@ function createElementActions(selector, index) {
|
|
|
1547
1577
|
return createElementProxy(indexedBase() + "::parent", null);
|
|
1548
1578
|
}
|
|
1549
1579
|
async function closest(targetSelector) {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
async () => {
|
|
1554
|
-
const exists = await driver().closest(selector, targetSelector, index);
|
|
1555
|
-
if (!exists) return null;
|
|
1556
|
-
return createElementProxy(`${indexedBase()}::closest(${targetSelector})`, null);
|
|
1557
|
-
}
|
|
1558
|
-
);
|
|
1580
|
+
const exists = await driver().closest(selector, targetSelector, index);
|
|
1581
|
+
if (!exists) return null;
|
|
1582
|
+
return createElementProxy(`${indexedBase()}::closest(${targetSelector})`, null);
|
|
1559
1583
|
}
|
|
1560
1584
|
function children(targetSelector) {
|
|
1561
1585
|
return createCollectionProxy(`${indexedBase()}::children(${targetSelector ?? ""})`);
|
|
@@ -2008,9 +2032,11 @@ function buildSpectra() {
|
|
|
2008
2032
|
const el = resolveTargetProxy(target);
|
|
2009
2033
|
await el.longPress(options);
|
|
2010
2034
|
},
|
|
2011
|
-
pressKey:
|
|
2012
|
-
|
|
2013
|
-
|
|
2035
|
+
pressKey: (key) => trackStep(
|
|
2036
|
+
"action",
|
|
2037
|
+
{ type: "action", key: "pressKey", target: void 0, args: [key] },
|
|
2038
|
+
() => driver().pressKey(key)
|
|
2039
|
+
),
|
|
2014
2040
|
grantPermission: async (name) => {
|
|
2015
2041
|
await driver().grantPermission(name);
|
|
2016
2042
|
},
|
|
@@ -2024,6 +2050,7 @@ function buildSpectra() {
|
|
|
2024
2050
|
clearMocks: () => {
|
|
2025
2051
|
driver().clearMocks();
|
|
2026
2052
|
},
|
|
2053
|
+
step: (title, fn) => trackGroup(title, fn),
|
|
2027
2054
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
2028
2055
|
onConsole: (listener) => {
|
|
2029
2056
|
const active = driver();
|
|
@@ -2062,6 +2089,7 @@ var init_spectra = __esm({
|
|
|
2062
2089
|
"use strict";
|
|
2063
2090
|
init_driver_context();
|
|
2064
2091
|
init_config();
|
|
2092
|
+
init_reporter();
|
|
2065
2093
|
init_custom_commands();
|
|
2066
2094
|
init_element_proxy();
|
|
2067
2095
|
RESERVED_COMMAND_NAMES = /* @__PURE__ */ new Set(["mount", "unmount", "registerCommand", "registerCommands"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testspectra/react-native",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "Native Android & iOS component test runner for React Native with TestSpectra Spectra.* DSL",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"testspectra",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"cross-spawn": "^7.0.6",
|
|
34
34
|
"esbuild": "^0.28.2",
|
|
35
|
-
"@testspectra/matchers": "1.3.
|
|
35
|
+
"@testspectra/matchers": "1.3.7"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=18.0.0",
|