@testspectra/react 1.1.14 → 1.2.1

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/cli.js CHANGED
@@ -71,6 +71,7 @@ export default defineConfig({
71
71
  plugins: [react()],
72
72
  define: {
73
73
  __TESTSPECTRA_AUTO_IMPORT_MANIFEST__: ${JSON.stringify(JSON.stringify(manifest))},
74
+ __TESTSPECTRA_PLUGINS__: ${JSON.stringify(JSON.stringify(opts.plugins ?? []))},
74
75
  __TESTSPECTRA_STEP_DELAY_MS__: ${JSON.stringify(opts.stepDelayMs)},
75
76
  __TESTSPECTRA_SEMANTIC_REPORTER__: ${JSON.stringify(opts.semanticReporter)},
76
77
  },
@@ -162,7 +163,8 @@ async function runComponentTests(options = {}) {
162
163
  semanticReporter,
163
164
  fileParallelism: options.concurrency !== 1,
164
165
  browserExecutable: options.browserExecutablePath,
165
- outputFile: options.outputFile
166
+ outputFile: options.outputFile,
167
+ plugins: options.plugins
166
168
  });
167
169
  const args = ["run", "--config", configPath];
168
170
  if (options.spec) {
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export interface RunComponentTestsOptions {
15
15
  outputFile?: string;
16
16
  concurrency?: number;
17
17
  browserExecutablePath?: string;
18
+ plugins?: string[];
18
19
  onLine?: (line: string) => void;
19
20
  }
20
21
 
@@ -28,6 +29,7 @@ export interface BundleServerOptions {
28
29
  packageDir?: string;
29
30
  manifest?: any;
30
31
  stepDelayMs?: number;
32
+ plugins?: string[];
31
33
  }
32
34
 
33
35
  export declare function startBundleServer(opts?: BundleServerOptions): Promise<BundleServer>;
package/dist/index.js CHANGED
@@ -588,6 +588,57 @@ var DomDriverBridge = class {
588
588
  });
589
589
  if (!ok) throw new Error("Element not found: " + JSON.stringify(selector));
590
590
  }
591
+ async blur(selector, index = null) {
592
+ const ok = await globalThis.__TS_RUNTIME__.pollCondition(async () => {
593
+ const el = resolveEl(selector, index);
594
+ if (!el) return false;
595
+ el.blur?.();
596
+ return true;
597
+ });
598
+ if (!ok) throw new Error("Element not found: " + JSON.stringify(selector));
599
+ }
600
+ async waitForElementRemoved(selector, timeoutMs = 5e3, index = null) {
601
+ const ok = await globalThis.__TS_RUNTIME__.pollCondition(async () => {
602
+ return !await this.isExisting(selector, index);
603
+ }, timeoutMs);
604
+ if (!ok) throw new Error("Element still exists after timeout: " + JSON.stringify(selector));
605
+ }
606
+ async waitForUndisplayed(selector, opts, index = null) {
607
+ const ok = await globalThis.__TS_RUNTIME__.pollCondition(async () => {
608
+ return !await this.isDisplayed(selector, index);
609
+ }, opts?.timeout ?? 5e3);
610
+ if (!ok) throw new Error("Element still displayed after timeout: " + JSON.stringify(selector));
611
+ }
612
+ async waitForClickable(selector, opts, index = null) {
613
+ return await globalThis.__TS_RUNTIME__.pollCondition(async () => {
614
+ return this.isClickable(selector, index);
615
+ }, opts?.timeout ?? 5e3);
616
+ }
617
+ async getBounds(selector, index = null) {
618
+ const el = resolveEl(selector, index);
619
+ if (!el) return { x: 0, y: 0, top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
620
+ const r = el.getBoundingClientRect();
621
+ return {
622
+ x: r.x,
623
+ y: r.y,
624
+ top: r.top,
625
+ right: r.right,
626
+ bottom: r.bottom,
627
+ left: r.left,
628
+ width: r.width,
629
+ height: r.height
630
+ };
631
+ }
632
+ async closest(selector, targetSelector, index = null) {
633
+ const el = resolveEl(selector, index);
634
+ if (!el) return null;
635
+ const ancestor = el.closest(targetSelector);
636
+ return ancestor ? ancestor.tagName.toLowerCase() : null;
637
+ }
638
+ async clickAt(x, y) {
639
+ const el = document.elementFromPoint(x, y);
640
+ el?.click();
641
+ }
591
642
  async dragDrop(sourceSelector, targetSelector, sourceIndex = null) {
592
643
  const src = resolveEl(sourceSelector, sourceIndex);
593
644
  const dest = resolveEl(targetSelector, null);
@@ -896,6 +947,7 @@ export default defineConfig({
896
947
  plugins: [react()],
897
948
  define: {
898
949
  __TESTSPECTRA_AUTO_IMPORT_MANIFEST__: ${JSON.stringify(JSON.stringify(manifest))},
950
+ __TESTSPECTRA_PLUGINS__: ${JSON.stringify(JSON.stringify(opts.plugins ?? []))},
899
951
  __TESTSPECTRA_STEP_DELAY_MS__: ${JSON.stringify(opts.stepDelayMs)},
900
952
  __TESTSPECTRA_SEMANTIC_REPORTER__: ${JSON.stringify(opts.semanticReporter)},
901
953
  },
@@ -987,7 +1039,8 @@ async function runComponentTests(options = {}) {
987
1039
  semanticReporter,
988
1040
  fileParallelism: options.concurrency !== 1,
989
1041
  browserExecutable: options.browserExecutablePath,
990
- outputFile: options.outputFile
1042
+ outputFile: options.outputFile,
1043
+ plugins: options.plugins
991
1044
  });
992
1045
  const args = ["run", "--config", configPath];
993
1046
  if (options.spec) {
@@ -1319,8 +1372,9 @@ ${exportLines.join("\n")}
1319
1372
  export default _react;
1320
1373
  `;
1321
1374
  }
1322
- function buildHarnessHtml(manifest, stepDelayMs) {
1375
+ function buildHarnessHtml(manifest, stepDelayMs, plugins = []) {
1323
1376
  const manifestJson = JSON.stringify(manifest);
1377
+ const pluginsJson = JSON.stringify(plugins);
1324
1378
  return `<!DOCTYPE html>
1325
1379
  <html>
1326
1380
  <head>
@@ -1342,6 +1396,7 @@ function buildHarnessHtml(manifest, stepDelayMs) {
1342
1396
  <body>
1343
1397
  <script type="module">
1344
1398
  window.__TESTSPECTRA_AUTO_IMPORT_MANIFEST__ = ${manifestJson};
1399
+ window.__TESTSPECTRA_PLUGINS__ = ${pluginsJson};
1345
1400
  window.__TESTSPECTRA_STEP_DELAY_MS__ = ${JSON.stringify(stepDelayMs)};
1346
1401
  window.__TESTSPECTRA_SEMANTIC_REPORTER__ = true;
1347
1402
  try {
@@ -1505,7 +1560,7 @@ async function startBundleServer(opts = {}) {
1505
1560
  getCachedBundle("runner", runnerEntrypoint).catch(() => {
1506
1561
  });
1507
1562
  }
1508
- const harnessHtml = buildHarnessHtml(manifest, stepDelayMs);
1563
+ const harnessHtml = buildHarnessHtml(manifest, stepDelayMs, opts.plugins ?? []);
1509
1564
  const handler = makeHandler(testRoot, packageDir, harnessHtml, setupEntrypoint, runnerEntrypoint);
1510
1565
  const server = http.createServer(handler);
1511
1566
  await new Promise((resolve, reject) => {