Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page type incompatibility when updating @playwright/test #1087

Open
1 task done
ritchieanesco opened this issue Jul 29, 2024 · 9 comments
Open
1 task done

Page type incompatibility when updating @playwright/test #1087

ritchieanesco opened this issue Jul 29, 2024 · 9 comments
Labels
PACKAGE: playwright question Further information is requested

Comments

@ritchieanesco
Copy link

Product

playwright

Product Version

4.9.1

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

Expectation

No type errors when updating @playwright/tests package

Actual

Page type error occurs when running tsc --noEmit after updating @playwright/tests package

How to Reproduce

  1. Use Page type from @playwright.tests package in your tests.
  2. Use a version of @axe-core/playwright that uses a older version of @playwright/tests.
  3. Run tsc --noEmit
@Zidious
Copy link
Contributor

Zidious commented Jul 29, 2024

Hey @ritchieanesco,

What version were you on and what version of @playwright/test caused the type break?

Thanks!

@Zidious Zidious added question Further information is requested PACKAGE: playwright labels Jul 29, 2024
@DyHex
Copy link

DyHex commented Aug 14, 2024

@Zidious

Type 'import("C:/Users/....../Playwright/node_modules/.pnpm/playwright-core@1.46.0/node_modules/playwright-core/types/types").Page' is not assignable to type 'import("C:/Users/....../Playwright/node_modules/.pnpm/playwright-core@1.45.3/node_modules/playwright-core/types/types").Page'.ts(2322)
index.d.ts(5, 5): The expected type comes from property 'page' which is declared here on type 'AxePlaywrightParams'

Generally get this error everytime I upgrade playwright/test to a new version

4lejandrito added a commit to jaimelr10/liferay-portal that referenced this issue Sep 27, 2024
4lejandrito added a commit to jaimelr10/liferay-portal that referenced this issue Sep 30, 2024
@florestankorp
Copy link

Same here!

@evadecker
Copy link

I'm also encountering this issue.

"@axe-core/playwright": "^4.10.1"
"@playwright/test": "^1.49.0"
"typescript": "^5.7.2"

tests/accessibility.spec.ts:22:9 - error ts(2322): Type 'import("/opt/build/repo/node_modules/.pnpm/playwright-core@1.49.0/node_modules/playwright-core/types/types").Page' is not assignable to type 'import("/opt/build/repo/node_modules/.pnpm/playwright-core@1.48.2/node_modules/playwright-core/types/types").Page'.

The types returned by 'evaluateHandle(...)' are incompatible between these types.

@charlesanim
Copy link

bumping this. Encountered issue

@charlesanim
Copy link

bumping one more time. @Zidious

@rypete
Copy link

rypete commented Dec 23, 2024

@Zidious We got this error going from @playwright/test 1.49.0 to 1.49.1 using @axe-core/playwright 4.10.1

@Zidious
Copy link
Contributor

Zidious commented Dec 24, 2024

Hello folks,

Apologies for the delays. I am not able to reproduce this error, I am using: @axe-core/playwright version ^4.10.1
and @playwright/test version ^1.49.1. Using this example:

import { AxeBuilder } from "@axe-core/playwright";
import { chromium } from "@playwright/test";

(async () => {
  const browser = await chromium.launch({ headless: true });
  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();
})();

Are you able to provide an example where this is reproducible and I'll be able to take a look?

@rypete
Copy link

rypete commented Dec 27, 2024

Thanks for that @Zidious. That example does work for me in an a fresh project.

I've dug deeper into my troubled project and found we had an additional playwright dependency that was causing the issue. The dependency in question was @playwright/experimental-ct-react. It was still on 1.49.0 and updating it to 1.49.1 to match the main @playwright/test dependency resolved the issue. Im guessing that dependency is augmenting the Page type.

Anyone else experiencing this issue have a look for other playwright dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PACKAGE: playwright question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants