Getting an intermittent promise resolution error with Percy IO, Cucumber and WebdriverIO

106 Views Asked by At

The error I am experiencing is:

[chrome 112.0.5615.138 windows #0-2] Error: function timed out, ensure the promise resolves within 60000 milliseconds
[chrome 112.0.5615.138 windows #0-2] Error: function timed out, ensure the promise resolves within 60000 milliseconds
[chrome 112.0.5615.138 windows #0-2]     at Timeout.<anonymous> (C:\Users\XXX\Documents\projects\xxx-visual-tests\node_modules\@cucumber\cucumber\lib\time.js:60:20)
[chrome 112.0.5615.138 windows #0-2]     at listOnTimeout (node:internal/timers:569:17)
[chrome 112.0.5615.138 windows #0-2]     at process.processTimers (node:internal/timers:512:7)

My code looks like this:

const { Given, When, Then } = require('@wdio/cucumber-framework');
const percySnapshot = require('@percy/webdriverio');
const HomePage = require('../../pageobjects/homepage/home.page');
const { DEFAULT_TIMEOUT } = require('../../pageobjects/homepage/home.page');

const pages = {
  page: HomePage
}

Given(/^I am on the home(\w+)$/, async (page) => {
  await pages[page].open()
  await expect(browser).toHaveTitle("XXX");
  });

When(/^the homepage has fully rendered$/, async () => {
  await browser.waitUntil(
    () => browser.execute(() => document.readyState === 'complete'),
    {
      timeout: DEFAULT_TIMEOUT,
      timeoutMsg: `Page did not load within ${DEFAULT_TIMEOUT} timeout window`
    }
    );
    await HomePage.allowCookies();
  });

Then(/^I take a screenshot of the homepage$/, async () => {
  await percySnapshot('XXX')
});

My package.json looks like this:

{
  "name": "my-new-project",
  "devDependencies": {
    "@percy/cli": "^1.21.0",
    "@percy/webdriverio": "^3.0.0",
    "@wdio/cli": "7.17.4",
    "@wdio/cucumber-framework": "7.17.3",
    "@wdio/local-runner": "7.17.4",
    "@wdio/spec-reporter": "7.17.3",
    "chromedriver": "^111.0.0",
    "wdio-chromedriver-service": "^8.1.1",
    "webdriverio": "7.18.1"
  },
  "scripts": {
    "wdio": "wdio run ./wdio.conf.js"
  }
}

The error occurs randomly and i'm not sure why. It fails on the Then I take a screenshot of the homepage step only. My implementation of the percySnapshot function is exactly as described on the Percy docs so i'm not sure what the issue could be.

Strangely, even when the step fails, sometimes the screenshot is still uploaded to the Percy dashboard.

https://docs.percy.io/docs/webdriverio

Any help would be appreciated. Thanks.

0

There are 0 best solutions below