Skip to content

feat: Allow to pass custom options to Puppeteer screenshot function #3145

@ryuran

Description

@ryuran

Prerequisites

Describe the Feature Request

We expect to be able to pass any options possible to puppeteer screenshot option.

Currently we have only ScreenshotOptions interface.
https://github.com/ionic-team/stencil/blob/main/src/testing/puppeteer/puppeteer-screenshot.ts#L138-L156

function createPuppeteerScreenshopOptions(opts: ScreenshotOptions) {
  const puppeteerOpts: puppeteer.ScreenshotOptions = {
    type: 'png',
    fullPage: opts.fullPage,
    omitBackground: opts.omitBackground,
    encoding: 'binary',
  };

  if (opts.clip) {
    puppeteerOpts.clip = {
      x: opts.clip.x,
      y: opts.clip.y,
      width: opts.clip.width,
      height: opts.clip.height,
    };
  }

  return puppeteerOpts;
}

Describe the Use Case

We spot this issue : puppeteer/puppeteer#7251

A resize event happen just before screenshot so it trigger some resize event listener able to redraw the component we try to screenshot.

This resize is unwanted but, with the current stencil testing API, we are not able to avoid it by the solution proposed in the issue: pass the option captureBeyondViewport: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: Want this? Upvote it!This PR or Issue may be a great consideration for a future idea.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions