question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Playwright stalls before half of the test finished.

See original GitHub issue

Context:

  • Playwright Version: 1.21.0
  • Operating System: Mac
  • Node.js version: v14.19.0
  • Browser: All
  • Extra: [any specific details about your environment]

System:

  • OS: macOS 12.3.1
  • Memory: 14.22 GB / 64.00 GB

Binaries:

  • Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node
  • Yarn: 1.22.18 - /usr/local/bin/yarn
  • npm: 8.5.5 - ~/.nvm/versions/node/v14.19.0/bin/npm

Languages:

  • Bash: 5.1.16 - /usr/local/bin/bash

Code Snippet

// @ts-check
const {
  test,
  expect
} = require('@playwright/test');

const path = require('path');

const patternTool = require('../tools/get-test');
const patternsToTest = patternTool.getPatterns();
const testConfigJson = require('./localStorage.json');

let currentPattern;

const currentTheme = 'yellow'


test.beforeEach(async ({
  page
}) => {

  await page.goto(`${currentPattern.path}`);

  await page.addInitScript(value => {
    window.localStorage.setItem('availableThemes', value);
    window.sessionStorage.setItem('currentTheme', currentTheme);
  }, testConfigJson);

});



for (const currentTest in patternsToTest) {
  // console.log(currentPattern);

  currentPattern = patternsToTest[currentTest];

  test.describe(`Theme ${currentTheme}`, () => {

    test(`Test: ${currentTest} - ${currentPattern.name}`, async ({
      page
    }) => {

      // await page.waitForLoadState('domcontentloaded');

      const screenshotPath = `./screenshots/${currentTheme}/${path.basename(currentPattern.path, '.html')}.png`

      expect(await page.screenshot()).toMatchSnapshot(screenshotPath, {
        threshold: 0.01,
        maxDiffPixelRatio: 0.1
      });

    });


  });

};

Describe the bug

After nearly having the test seems to stall and I can wait for hours. Nothing moving forward anymore.

Screenshot 2022-04-18 at 18 15 46

Is the bug on my side or is it really a bug.

Try to test a style guide and various themes. The style guide is based on https://patternlab.io Assets I like to test can be found here: https://lab.n8d.studio/htwoo/htwoo-core/?p=all

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yury-scommented, Apr 20, 2022

The problem is that getPatterns is not idempotent, on each call it will increase number of entries in allPatterns. For 4 files it is called 4 times in the test runner and for each file it generates 163, 2163, 3163, 4*163 tests. But when worker picks up the same file it will run getPatterns in a fresh context and it will always return 163 tests. We should definitely fix it on the playwright side and provide a clear error message instead of hanging. On your end you can simply move https://github.com/n8design/htwoo/blob/f5e345adc428a50b4c72139233916bc44d6fc0a2/htwoo-core/tools/get-test.js#L49-L63 outside of the function to make sure it runs only once.

1reaction
yury-scommented, Apr 20, 2022

I can reproduce it (on linux), investigating.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright test fails on Azure Devops Pipeline and pipeline ...
The reason is that your "CI" environment variable in the virtual server is not true at the moment you are running the tests....
Read more >
Browser.Playwright — RPA Framework documentation
If automatic closing level is TEST, contexts and pages that are created during a single test are automatically closed when the test ends....
Read more >
Testing HTTP - Artillery.io
If a response to any request takes longer than 10 seconds, Artillery will abort the request and raise an ETIMEDOUT error. To increase...
Read more >
Avoiding hard waits in Playwright and Puppeteer
In this case, our hard wait terminates and our click action is attempted too early. The script terminates with an error, possibly of...
Read more >
Playwright changelog - Awesome Node.js - LibHunt
It allows testing Chromium, Firefox and WebKit with a single API. All Versions ... #3499 - [BUG] Playwright does not see iframe element...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found