chore: test on Node.js 20 (#22651)

Fixes https://github.com/microsoft/playwright/issues/22582
This commit is contained in:
Max Schmitt 2023-05-30 18:16:34 +02:00 committed by GitHub
parent d6e24fafe8
commit 1f7223eb21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 8 deletions

View file

@ -29,7 +29,6 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
# Component tests require Node.js 16+ (they require ESM via TS)
node-version: 16 node-version: 16
- run: npm i -g npm@8 - run: npm i -g npm@8
- run: npm ci - run: npm ci

View file

@ -38,6 +38,9 @@ jobs:
- os: ubuntu-22.04 - os: ubuntu-22.04
node-version: 18 node-version: 18
browser: chromium browser: chromium
- os: ubuntu-22.04
node-version: 20
browser: chromium
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -241,7 +244,6 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
# Component tests require Node.js 16+ (they require ESM via TS)
node-version: 16 node-version: 16
- run: npm ci - run: npm ci
env: env:

View file

@ -102,9 +102,9 @@ jobs:
matrix: matrix:
include: include:
- os: ubuntu-latest - os: ubuntu-latest
node_version: "^18.0.0" node_version: 18
- os: ubuntu-latest - os: ubuntu-latest
node_version: "^16.0.0" node_version: 20
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

View file

@ -256,7 +256,7 @@ export class TestServer {
if (err) { if (err) {
response.statusCode = 404; response.statusCode = 404;
response.setHeader('Content-Type', 'text/plain'); response.setHeader('Content-Type', 'text/plain');
response.end(`File not found: ${filePath}`); response.end(request.method !== 'HEAD' ? `File not found: ${filePath}` : null);
return; return;
} }
const extension = filePath.substring(filePath.lastIndexOf('.') + 1); const extension = filePath.substring(filePath.lastIndexOf('.') + 1);
@ -269,9 +269,9 @@ export class TestServer {
const result = await gzipAsync(data); const result = await gzipAsync(data);
// The HTTP transaction might be already terminated after async hop here. // The HTTP transaction might be already terminated after async hop here.
if (!response.writableEnded) if (!response.writableEnded)
response.end(result); response.end(request.method !== 'HEAD' ? result : null);
} else { } else {
response.end(data); response.end(request.method !== 'HEAD' ? data : null);
} }
} }

View file

@ -209,5 +209,8 @@ it('should handle malformed file', async ({ contextFactory }, testInfo) => {
const error = await contextFactory({ const error = await contextFactory({
storageState: file, storageState: file,
}).catch(e => e); }).catch(e => e);
expect(error.message).toContain(`Error reading storage state from ${file}:\nUnexpected token o in JSON at position 1`); if (+process.versions.node.split('.')[0] > 18)
expect(error.message).toContain(`Error reading storage state from ${file}:\nUnexpected token 'o', \"not-json\" is not valid JSON`);
else
expect(error.message).toContain(`Error reading storage state from ${file}:\nUnexpected token o in JSON at position 1`);
}); });