@testdino/playwright 1.0.2 → 1.0.4

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.mjs CHANGED
@@ -384,7 +384,7 @@ var EventBuffer = class {
384
384
  events = [];
385
385
  maxSize;
386
386
  onFlush;
387
- isFlushing = false;
387
+ flushPromise = null;
388
388
  constructor(options) {
389
389
  this.maxSize = options.maxSize || 10;
390
390
  this.onFlush = options.onFlush || (async () => {
@@ -402,12 +402,30 @@ var EventBuffer = class {
402
402
  }
403
403
  /**
404
404
  * Flush all buffered events
405
+ * If a flush is already in progress, waits for it to complete then flushes any new events
405
406
  */
406
407
  async flush() {
407
- if (this.isFlushing || this.events.length === 0) {
408
+ if (this.flushPromise) {
409
+ await this.flushPromise;
410
+ if (this.events.length > 0) {
411
+ return this.flush();
412
+ }
413
+ return;
414
+ }
415
+ if (this.events.length === 0) {
408
416
  return;
409
417
  }
410
- this.isFlushing = true;
418
+ this.flushPromise = this.doFlush();
419
+ try {
420
+ await this.flushPromise;
421
+ } finally {
422
+ this.flushPromise = null;
423
+ }
424
+ }
425
+ /**
426
+ * Internal flush implementation
427
+ */
428
+ async doFlush() {
411
429
  try {
412
430
  const eventsToFlush = [...this.events];
413
431
  this.events = [];
@@ -415,8 +433,6 @@ var EventBuffer = class {
415
433
  } catch (error) {
416
434
  console.error("Failed to flush events:", error);
417
435
  throw error;
418
- } finally {
419
- this.isFlushing = false;
420
436
  }
421
437
  }
422
438
  /**
@@ -1776,7 +1792,7 @@ var TestdinoReporter = class {
1776
1792
  mappedConfig.debug = cliConfig.debug;
1777
1793
  }
1778
1794
  if (cliConfig.ciRunId !== void 0 && typeof cliConfig.ciRunId === "string") {
1779
- mappedConfig.ciBuildId = cliConfig.ciRunId;
1795
+ mappedConfig.ciRunId = cliConfig.ciRunId;
1780
1796
  }
1781
1797
  if (cliConfig.artifacts !== void 0 && typeof cliConfig.artifacts === "boolean") {
1782
1798
  mappedConfig.artifacts = cliConfig.artifacts;
@@ -1878,8 +1894,23 @@ var TestdinoReporter = class {
1878
1894
  type: "run:begin",
1879
1895
  runId: this.runId,
1880
1896
  metadata,
1897
+ ciRunId: this.config.ciRunId,
1898
+ // Include ciRunId for shard grouping
1881
1899
  ...this.getEventMetadata()
1882
1900
  };
1901
+ if (this.config.debug) {
1902
+ console.log(`\u{1F50D} TestDino: run:begin event details:`);
1903
+ console.log(` runId: ${this.runId}`);
1904
+ console.log(` ciRunId: ${this.config.ciRunId ?? "(not set)"}`);
1905
+ console.log(` shard: ${config?.shard ? `${config.shard.current}/${config.shard.total}` : "(not sharded)"}`);
1906
+ if (metadata.skeleton) {
1907
+ console.log(` skeleton.totalTests: ${metadata.skeleton.totalTests}`);
1908
+ console.log(` skeleton.suites: ${metadata.skeleton.suites?.length ?? 0}`);
1909
+ console.log(` skeleton: ${JSON.stringify(metadata.skeleton, null, 2)}`);
1910
+ } else {
1911
+ console.log(` skeleton: (not available)`);
1912
+ }
1913
+ }
1883
1914
  await this.sendEvents([beginEvent]);
1884
1915
  this.registerSignalHandlers();
1885
1916
  return true;
@@ -2083,6 +2114,9 @@ var TestdinoReporter = class {
2083
2114
  */
2084
2115
  async onEnd(result) {
2085
2116
  if (this.quotaExceeded) {
2117
+ if (this.pendingTestEndPromises.size > 0) {
2118
+ await Promise.allSettled(Array.from(this.pendingTestEndPromises));
2119
+ }
2086
2120
  console.log("\u2705 TestDino: Tests completed (quota limit reached; not streamed to TestDino)");
2087
2121
  this.wsClient?.close();
2088
2122
  this.removeSignalHandlers();
@@ -2572,7 +2606,7 @@ var TestdinoReporter = class {
2572
2606
  try {
2573
2607
  await Promise.race([
2574
2608
  Promise.allSettled(Array.from(this.pendingTestEndPromises)),
2575
- this.timeoutPromise(500, "Pending events timeout")
2609
+ this.timeoutPromise(2e3, "Pending events timeout")
2576
2610
  ]);
2577
2611
  } catch {
2578
2612
  }