@testspectra/react 1.2.7 → 1.2.8

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 CHANGED
@@ -197,6 +197,8 @@ function mockResponseBodyText(body) {
197
197
 
198
198
  // ../../core/worker-runtime/src/dsl/selector_resolver.ts
199
199
  function parseElementSentinel(selector) {
200
+ const nth = /^(.*)::nth\((-?\d+)\)$/.exec(selector);
201
+ if (nth) return { kind: "nth", base: nth[1], arg: nth[2] };
200
202
  const closest = /^(.*)::closest\((.+)\)$/.exec(selector);
201
203
  if (closest) return { kind: "closest", base: closest[1], arg: closest[2] };
202
204
  const children = /^(.*)::children\((.*)\)$/.exec(selector);
@@ -429,6 +431,10 @@ function matchesSelector(el, selector) {
429
431
  function resolveSentinelList(raw, parent) {
430
432
  const sentinel = parseElementSentinel(raw);
431
433
  if (!sentinel) return void 0;
434
+ if (sentinel.kind === "nth") {
435
+ const el = resolveScopedEl(sentinel.base, Number.parseInt(sentinel.arg, 10));
436
+ return el ? [el] : [];
437
+ }
432
438
  const baseTarget = parent ? { selector: sentinel.base, index: null, parent } : sentinel.base;
433
439
  const base = resolveScopedEl(baseTarget, null);
434
440
  if (sentinel.kind === "parent") return base?.parentElement ? [base.parentElement] : [];