@testspectra/react-native 1.2.23 → 1.3.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/index.js +32 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -699,28 +699,48 @@ function getAssertionTimeoutMs() {
|
|
|
699
699
|
function emitEvent(tag, payload) {
|
|
700
700
|
console.log(`[${tag}] ${payload}`);
|
|
701
701
|
}
|
|
702
|
+
function describeTarget(target) {
|
|
703
|
+
if (target === void 0 || target === null) return "";
|
|
704
|
+
if (typeof target === "string") return target;
|
|
705
|
+
const scoped = target;
|
|
706
|
+
return scoped.parent ? `${scoped.selector} within ${describeTarget(scoped.parent)}` : String(scoped.selector ?? "");
|
|
707
|
+
}
|
|
708
|
+
function delayApplies(index) {
|
|
709
|
+
const ranges = typeof process !== "undefined" ? process.env?.TESTSPECTRA_DELAY_STEPS : void 0;
|
|
710
|
+
if (!ranges) return true;
|
|
711
|
+
return ranges.split(",").some((range) => {
|
|
712
|
+
const [from, to = from] = range.split("-").map((n) => Number(n.trim()));
|
|
713
|
+
return Number.isFinite(from) && index >= from && index <= to;
|
|
714
|
+
});
|
|
715
|
+
}
|
|
702
716
|
async function trackStep(category, payloadObj, fn) {
|
|
703
717
|
const config = getWorkerConfig();
|
|
704
718
|
const currentTest = globalThis.__CURRENT_TEST_TITLE__ || globalThis.__CURRENT_TEST_ID__ || "";
|
|
705
719
|
const workerId = globalThis.__TESTSPECTRA_WORKER_ID__;
|
|
706
720
|
if (currentTest && !payloadObj.test) payloadObj.test = currentTest;
|
|
707
721
|
if (workerId !== void 0 && payloadObj.workerId === void 0) payloadObj.workerId = workerId;
|
|
708
|
-
|
|
709
|
-
|
|
722
|
+
stepContext = { index: stepContext.index + 1, label: `${payloadObj.key} ${describeTarget(payloadObj.target)}`.trim() };
|
|
723
|
+
payloadObj.step = stepContext.index;
|
|
724
|
+
lastResolved = void 0;
|
|
725
|
+
emitEvent("TESTSPECTRA_STEP_START", JSON.stringify(payloadObj));
|
|
710
726
|
const start = Date.now();
|
|
727
|
+
const withResolved = () => {
|
|
728
|
+
if (lastResolved) payloadObj.resolved = lastResolved;
|
|
729
|
+
return JSON.stringify(payloadObj);
|
|
730
|
+
};
|
|
711
731
|
try {
|
|
712
732
|
const res = await fn();
|
|
713
733
|
const duration = Date.now() - start;
|
|
714
|
-
emitEvent("TESTSPECTRA_STEP_PASS", `${
|
|
734
|
+
emitEvent("TESTSPECTRA_STEP_PASS", `${withResolved()} (${duration}ms)`);
|
|
715
735
|
recordDuration(`step:${payloadObj.key}`, category, duration, { test: currentTest, target: payloadObj.target });
|
|
716
736
|
const delay = config.stepDelayMs || 0;
|
|
717
|
-
if (delay > 0) {
|
|
737
|
+
if (delay > 0 && delayApplies(stepContext.index)) {
|
|
718
738
|
await new Promise((r) => setTimeout(r, delay));
|
|
719
739
|
}
|
|
720
740
|
return res;
|
|
721
741
|
} catch (err) {
|
|
722
742
|
const duration = Date.now() - start;
|
|
723
|
-
emitEvent("TESTSPECTRA_STEP_FAIL", `${
|
|
743
|
+
emitEvent("TESTSPECTRA_STEP_FAIL", `${withResolved()} (${duration}ms)`);
|
|
724
744
|
recordDuration(`step:${payloadObj.key}`, category, duration, {
|
|
725
745
|
test: currentTest,
|
|
726
746
|
target: payloadObj.target,
|
|
@@ -746,12 +766,13 @@ async function pollCondition(fn, timeoutMs, intervalMs = 15) {
|
|
|
746
766
|
return false;
|
|
747
767
|
}
|
|
748
768
|
}
|
|
749
|
-
var activeDurationSink;
|
|
769
|
+
var activeDurationSink, stepContext, lastResolved;
|
|
750
770
|
var init_reporter = __esm({
|
|
751
771
|
"../../core/worker-runtime/src/harness/reporter.ts"() {
|
|
752
772
|
"use strict";
|
|
753
773
|
init_config();
|
|
754
774
|
activeDurationSink = null;
|
|
775
|
+
stepContext = { index: 0, label: "" };
|
|
755
776
|
}
|
|
756
777
|
});
|
|
757
778
|
|
|
@@ -1959,6 +1980,11 @@ function buildSpectra() {
|
|
|
1959
1980
|
clearMocks: () => {
|
|
1960
1981
|
driver().clearMocks();
|
|
1961
1982
|
},
|
|
1983
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
1984
|
+
onConsole: (listener) => {
|
|
1985
|
+
const active = driver();
|
|
1986
|
+
return typeof active.onConsole === "function" ? active.onConsole(listener) : () => void 0;
|
|
1987
|
+
},
|
|
1962
1988
|
get browser() {
|
|
1963
1989
|
return driver();
|
|
1964
1990
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testspectra/react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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.
|
|
35
|
+
"@testspectra/matchers": "1.3.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": ">=18.0.0",
|