axe-core-npm icon indicating copy to clipboard operation
axe-core-npm copied to clipboard

Depend on playwright-core rather on playwright

Open mxschmitt opened this issue 3 years ago • 1 comments

Currently axe playwright depends on playwright. This means that if you install axe playwright, that all browsers get automatically downloaded, since we download the browsers in the postinstall step.

Since around half a year or so, playwright depends on playwright-core and @playwright/test depends on playwright-core.

I'd recommend to also depend on playwright-core instead, which will give you the correct types, but keep the flexibility up to the user which browser he wants to install. Also @playwright/test does not install all the browsers anymore, you need to explicitly call npx playwright install to install them or just one of them.

See here: https://github.com/dequelabs/axe-core-npm/blob/develop/packages/playwright/package.json

mxschmitt avatar Jun 30 '22 09:06 mxschmitt

Hey @mxschmitt

Thank you for submitting the recommendation we will discuss this and update the package as needed.

michael-siek avatar Jun 30 '22 13:06 michael-siek

@mxschmitt did you find a work around for this? Unable to install @axe-core/playwright due to this issue.

bigballofmonoid avatar Aug 31 '22 16:08 bigballofmonoid

Validated this using @axe-core/playwright-4.4.5-alpha.313 Here while validating, instead of installing playwright, installed playwright-core_1.25.2 (so playwright- not exists in the dependencies list) Run the js script

const AxeBuilder = require('@axe-core/playwright').default;
const playwright = require('playwright-core');

(async () => {
  const browser = await playwright.chromium.launch();
  const context = await browser.newContext();
  const page = await context.newPage();
  await page.goto('https://dequeuniversity.com/demo/mars/');

  try {
    const results = await new AxeBuilder({ page }).analyze();
    console.log(results);
  } catch (e) {
    // do something with the error
  }
  await browser.close();
})();

and it is giving expected results holding axe-core_4.4.3 image

Also @playwright/test package is working with playwright image image

@michael-siek , But here observed one thing: Even If I pass const playwright = require('playwright'); instead of const playwright = require('playwright-core'); seeing the expected results.

padmavemulapati avatar Sep 19 '22 08:09 padmavemulapati