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

Playwright tests broken on Node.js ≥23.6.0 due to type stripping feature #902

Open
praseodym opened this issue Jan 24, 2025 · 3 comments
Labels
frontend Issues or pull requests that relate to the frontend tests Issues or pull requests that relate to tests

Comments

@praseodym
Copy link
Contributor

praseodym commented Jan 24, 2025

Node.js 23.6.0 enables the type stripping feature by default. This breaks our Playwright tests:

$ npm run e2e:d2d -- --project chrome

> [email protected] e2e:d2d
> cross-env LOCAL_CI=true playwright test -c playwright.d2d.config.ts --project chrome

(node:18607) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

[..]

SyntaxError:   x TypeScript enum is not supported in strip-only mode
   ,-[1:1]
 1 | ,-> export enum ApiResponseStatus {
 2 | |     Success,
 3 | |     ClientError,
 4 | |     ServerError,
 5 | `-> }
   `----

SyntaxError:   x TypeScript parameter property is not supported in strip-only mode
    ,-[8:1]
  5 | 
  6 |   readonly downloadZip: Locator;
  7 | 
  8 |   constructor(protected readonly page: Page) {
    :                                  ^^^^^^^^^^
  9 |     this.downloadPdf = page.getByRole("button", { name: "Download los proces-verbaal" });
 10 |     this.downloadZip = page.getByRole("button", { name: "Download proces-verbaal met telbestand" });
 11 |   }
    `----

[..]

We are currently requiring Node.js 22 (LTS) and don't support Node.js 23 officially, but it might be an issue that we have to resolve at some point in the future.

@praseodym praseodym added frontend Issues or pull requests that relate to the frontend tests Issues or pull requests that relate to tests labels Jan 24, 2025
@github-project-automation github-project-automation bot moved this to Options in Abacus Jan 24, 2025
@praseodym praseodym changed the title Playwright tests broken on Node.js ≥23.6.0 due to Type Stripping feature Playwright tests broken on Node.js ≥23.6.0 due to type stripping feature Jan 24, 2025
@jschuurk-kr
Copy link
Contributor

jschuurk-kr commented Jan 24, 2025

Playwright issue says its not their problem and recommends using --experimental-transform-types as mentioned in the Node.js docs linked in the description of this issue.

Tangentially, the Playwright docs say about TypeScript: "Note that Playwright does not check the types and will run tests even if there are non-critical TypeScript compilation errors. We recommend you run TypeScript compiler alongside Playwright."

@praseodym
Copy link
Contributor Author

I found that issue too, but find it strange that Node.js is now suddenly running code with TypeScript types included. I'd expected the TypeScript types to be stripped out before running regardless of the Node.js version.

@MarkusJLechner
Copy link

MarkusJLechner commented Jan 30, 2025

Edit: will post that to playwright issue.

I ran into the same problem. After removing all enums, Playwright completely breaks with a SyntaxError: Invalid or unexpected token error. The issue occurs when using npx playwright or pnpm exec playwright. Inside node_modules/.bin/playwright, the command is defined as:

node "$basedir/../playwright/cli.js" "$@"

For Node.js 23+, this needs to be changed to:

node --no-experimental-strip-types "$basedir/../playwright/cli.js" "$@"

Without this change, the tests won’t start. Since Playwright has its own mechanism for running TypeScript files, Node.js interferes with its type-stripping feature.

Reference: Node.js TypeScript API
See also: Full TypeScript Support

Temporary Solution

Until this is fixed, in package.json I use:

"scripts": {
  "test": "node --no-experimental-strip-types node_modules/playwright/cli.js test"
}

Error

(node:567908) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
SyntaxError: Invalid or unexpected token
    at compileSourceTextModule (node:internal/modules/esm/utils:338:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:106:18)
    at ModuleLoader.<anonymous> (node:internal/modules/esm/translators:549:10)
    at ModuleLoader.#translate (node:internal/modules/esm/loader:470:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:517:27)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Issues or pull requests that relate to the frontend tests Issues or pull requests that relate to tests
Projects
Status: Options
Development

No branches or pull requests

3 participants