garris / BackstopJS

Catch CSS curve balls.
http://backstopjs.org
MIT License
6.66k stars 602 forks source link

Change puppeteer's waitForTimeout into direct setTimeout #1554

Closed maciej-siola closed 4 months ago

maciej-siola commented 4 months ago

Small fix to address #1553

In puppeteer waitForTimeout was implemented this way:

  /**
   * @deprecated Replace with `new Promise(r => setTimeout(r, milliseconds));`.
   *
   * Causes your script to wait for the given number of milliseconds.
   *
   * @remarks
   * It's generally recommended to not wait for a number of seconds, but instead
   * use {@link Frame.waitForSelector}, {@link Frame.waitForXPath} or
   * {@link Frame.waitForFunction} to wait for exactly the conditions you want.
   *
   * @example
   *
   * Wait for 1 second:
   *
   * ```ts
   * await frame.waitForTimeout(1000);
   * ```
   *
   * @param milliseconds - the number of milliseconds to wait.
   */
  async waitForTimeout(milliseconds: number): Promise<void> {
    return await new Promise(resolve => {
      setTimeout(resolve, milliseconds);
    });
  }

Therefore it should be sufficient to simply replace function calls with direct setTimeout.

furai commented 4 months ago

Thanks @maciej-siola & @garris for taking care of this! When can we expect a new release with the fix?

garris commented 4 months ago

6.3.21 was just pushed to NPM & Docker Hub. Thanks to everyone who helped get this patched!