@testspectra/react-native 1.2.14 → 1.2.16

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.
Files changed (2) hide show
  1. package/dist/index.js +48 -1
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1119,6 +1119,33 @@ var init_assertions = __esm({
1119
1119
  }
1120
1120
  });
1121
1121
 
1122
+ // ../../core/worker-runtime/src/dsl/custom_commands.ts
1123
+ function addCustomCommand(name, command) {
1124
+ customCommands.set(name, command);
1125
+ }
1126
+ function listCustomCommands() {
1127
+ return customCommands.entries();
1128
+ }
1129
+ var customCommands;
1130
+ var init_custom_commands = __esm({
1131
+ "../../core/worker-runtime/src/dsl/custom_commands.ts"() {
1132
+ "use strict";
1133
+ customCommands = /* @__PURE__ */ new Map();
1134
+ }
1135
+ });
1136
+
1137
+ // ../../core/worker-runtime/src/dsl/element_scope.ts
1138
+ function markElementScope(proxy, scope) {
1139
+ Object.defineProperty(proxy, ELEMENT_SCOPE, { value: scope, enumerable: false });
1140
+ }
1141
+ var ELEMENT_SCOPE;
1142
+ var init_element_scope = __esm({
1143
+ "../../core/worker-runtime/src/dsl/element_scope.ts"() {
1144
+ "use strict";
1145
+ ELEMENT_SCOPE = /* @__PURE__ */ Symbol("testspectra.elementScope");
1146
+ }
1147
+ });
1148
+
1122
1149
  // ../../core/worker-runtime/src/dsl/element_state.ts
1123
1150
  function createElementState(selector, index) {
1124
1151
  const driver = () => getActiveDriver();
@@ -1212,7 +1239,7 @@ function createElementProxy(selector, index = null) {
1212
1239
  const actions = createElementActions(selector, index);
1213
1240
  const state = createElementState(selector, index);
1214
1241
  const assertions = createElementAssertions(selector, index, state);
1215
- return {
1242
+ const proxy = {
1216
1243
  selector: selectorTextValue,
1217
1244
  index: resolvedIndex,
1218
1245
  ...actions,
@@ -1232,6 +1259,13 @@ function createElementProxy(selector, index = null) {
1232
1259
  });
1233
1260
  }
1234
1261
  };
1262
+ markElementScope(proxy, toScopedSelector(selector, index));
1263
+ const members = proxy;
1264
+ for (const [name, command] of listCustomCommands()) {
1265
+ if (name in members) continue;
1266
+ members[name] = (...args) => command.apply(proxy, args);
1267
+ }
1268
+ return proxy;
1235
1269
  }
1236
1270
  function createCollectionProxy(selector) {
1237
1271
  const driver = () => getActiveDriver();
@@ -1367,6 +1401,8 @@ var init_element_proxy = __esm({
1367
1401
  "use strict";
1368
1402
  init_driver_context();
1369
1403
  init_reporter();
1404
+ init_custom_commands();
1405
+ init_element_scope();
1370
1406
  init_element_actions();
1371
1407
  init_assertions();
1372
1408
  init_element_state();
@@ -1577,6 +1613,13 @@ var init_element_actions = __esm({
1577
1613
  }
1578
1614
  });
1579
1615
 
1616
+ // ../../core/worker-runtime/src/dsl/typed_value.ts
1617
+ var init_typed_value = __esm({
1618
+ "../../core/worker-runtime/src/dsl/typed_value.ts"() {
1619
+ "use strict";
1620
+ }
1621
+ });
1622
+
1580
1623
  // ../../core/worker-runtime/src/dsl/keyboard.ts
1581
1624
  var init_keyboard = __esm({
1582
1625
  "../../core/worker-runtime/src/dsl/keyboard.ts"() {
@@ -1928,6 +1971,7 @@ function buildSpectra() {
1928
1971
  throw new Error(`[TestSpectra] Custom command "${name}" collides with a built-in Spectra method.`);
1929
1972
  }
1930
1973
  spectra2[name] = command;
1974
+ addCustomCommand(name, command);
1931
1975
  };
1932
1976
  spectra2.registerCommands = (commands) => {
1933
1977
  for (const [name, command] of Object.entries(commands)) {
@@ -1942,6 +1986,7 @@ var init_spectra = __esm({
1942
1986
  "use strict";
1943
1987
  init_driver_context();
1944
1988
  init_config();
1989
+ init_custom_commands();
1945
1990
  init_element_proxy();
1946
1991
  RESERVED_COMMAND_NAMES = /* @__PURE__ */ new Set(["mount", "unmount", "registerCommand", "registerCommands"]);
1947
1992
  VALID_COMMAND_NAME = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
@@ -1955,6 +2000,8 @@ var init_dsl = __esm({
1955
2000
  init_assertions();
1956
2001
  init_element_actions();
1957
2002
  init_element_proxy();
2003
+ init_element_scope();
2004
+ init_typed_value();
1958
2005
  init_element_state();
1959
2006
  init_keyboard();
1960
2007
  init_mock_intercept();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testspectra/react-native",
3
- "version": "1.2.14",
3
+ "version": "1.2.16",
4
4
  "description": "Native Android & iOS component test runner for React Native with TestSpectra Spectra.* DSL",
5
5
  "keywords": [
6
6
  "testspectra",
@@ -32,8 +32,7 @@
32
32
  "dependencies": {
33
33
  "cross-spawn": "^7.0.6",
34
34
  "esbuild": "^0.28.2",
35
- "@testspectra/matchers": "1.2.14",
36
- "@testspectra/worker-runtime": "1.0.0"
35
+ "@testspectra/matchers": "1.2.16"
37
36
  },
38
37
  "peerDependencies": {
39
38
  "react": ">=18.0.0",
@@ -44,7 +43,8 @@
44
43
  "@types/node": "^20.14.0",
45
44
  "@types/react": "^18.3.12",
46
45
  "@types/react-native": "^0.73.0",
47
- "typescript": "^5.6.3"
46
+ "typescript": "^5.6.3",
47
+ "@testspectra/worker-runtime": "1.0.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "node scripts/build.js",