Skip to content

page.evaluate: TypeError: Cannot read properties of null (reading 'sheet') at serializeCSSOM #1168

Closed
@branislav-remen

Description

The problem

After last update of @percy/cli I get error page.evaluate: TypeError: Cannot read properties of null (reading 'sheet') at serializeCSSOM when running percy exec ... script.

Environment

  • Node version: 14.18.1
  • @percy/cli version: 1.19.0-alpha.0
  • Version of Percy SDK you’re using: "@percy/playwright": "1.0.4",
  • If needed, a build or snapshot ID: -
  • OS version: MacOS 12.6.2
  • Type of shell command-line [interface]: shell
  • Chromium Version 105.0.5195.19 (playwright build 1019)

Details

We are using component library which uses Shadow DOM. After upgrade of your CLI to try Shadow DOM support it is not working. The same code works with previous version of cli 1.17.0.

We are using Playwright test runner.
Running playwright test script (without percy exec) works. (playwright test visualRegression).

Debug logs

> percy exec -- playwright test visualRegression

[percy] Percy has started!
[percy] Running "playwright test visualRegression"

Running 24 tests using 1 worker

     1 [chromium] › src/tests/visualRegression.spec.ts:22:1 › Registrations page
  ✓  1 [chromium] › src/tests/visualRegression.spec.ts:22:1 › Registrations page (4s)
[percy] Could not take DOM snapshot "Registrations page-list"
[percy] Error: page.evaluate: TypeError: Cannot read properties of null (reading 'sheet')
    at serializeCSSOM (eval at evaluate (:192:30), <anonymous>:159:59)
    at Object.serializeDOM (eval at evaluate (:192:30), <anonymous>:502:9)
    at eval (eval at evaluate (:192:30), <anonymous>:3:23)
    at UtilityScript.evaluate (<anonymous>:194:17)
    at UtilityScript.<anonymous> (<anonymous>:1:44)
...

Code to reproduce issue

percy.yml:

version: 2
snapshot:
  widths:
    - 375
    - 1280
  minHeight: 1024
  percyCSS: "#debugModal, #debugBtn { display: none }"
discovery:
  allowedHostnames: [ ]
  disallowedHostnames: [ ]
  networkIdleTimeout: 100
upload:
  files: "**/*.{png,jpg,jpeg}"
  ignore: ""
  stripExtensions: false

test script: "test:percy": "percy exec -- playwright test visualRegression",

Example of test:

test('Add Main Registration page', async ({ page }, testInfo) => {
  await page.goto(`${getAppUrl()}/add-registration`, { waitUntil: 'networkidle' });

  await page.waitForSelector('.Wizard__SelectionWrapper');
  await percySnapshot(page, getScreenshotName(testInfo));
});

Playwright config (I also tried default config and it doesn't work):

import { PlaywrightTestConfig, devices } from '@playwright/test';

const config: PlaywrightTestConfig = {
  projects: [
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
      },
    },
  ],
};
export default config;

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions