@testdino/playwright 1.0.2 → 1.0.3

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
  /**
@@ -2083,6 +2099,9 @@ var TestdinoReporter = class {
2083
2099
  */
2084
2100
  async onEnd(result) {
2085
2101
  if (this.quotaExceeded) {
2102
+ if (this.pendingTestEndPromises.size > 0) {
2103
+ await Promise.allSettled(Array.from(this.pendingTestEndPromises));
2104
+ }
2086
2105
  console.log("\u2705 TestDino: Tests completed (quota limit reached; not streamed to TestDino)");
2087
2106
  this.wsClient?.close();
2088
2107
  this.removeSignalHandlers();
@@ -2572,7 +2591,7 @@ var TestdinoReporter = class {
2572
2591
  try {
2573
2592
  await Promise.race([
2574
2593
  Promise.allSettled(Array.from(this.pendingTestEndPromises)),
2575
- this.timeoutPromise(500, "Pending events timeout")
2594
+ this.timeoutPromise(2e3, "Pending events timeout")
2576
2595
  ]);
2577
2596
  } catch {
2578
2597
  }