Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: remove check for node < 16 (#33301)

Yury Semikhatskyf98531baee31
diff --git a/packages/playwright-core/src/utilsBundle.ts b/packages/playwright-core/src/utilsBundle.ts
index f9dc8347f7..f57a6346f7 100644
--- a/packages/playwright-core/src/utilsBundle.ts
+++ b/packages/playwright-core/src/utilsBundle.ts
@@ -43,12 +43,8 @@ import type { StackFrame } from '@protocol/channels';
const StackUtils: typeof import('../bundles/utils/node_modules/@types/stack-utils') = require('./utilsBundleImpl').StackUtils;
const stackUtils = new StackUtils({ internals: StackUtils.nodeInternals() });
-const nodeInternals = StackUtils.nodeInternals();
-const nodeMajorVersion = +process.versions.node.split('.')[0];
export function parseStackTraceLine(line: string): StackFrame | null {
- if (!process.env.PWDEBUGIMPL && nodeMajorVersion < 16 && nodeInternals.some(internal => internal.test(line)))
- return null;
const frame = stackUtils.parseLine(line);
if (!frame)
return null;
diff --git a/packages/playwright/src/common/configLoader.ts b/packages/playwright/src/common/configLoader.ts
index 37a886d3e8..13d7eac187 100644
--- a/packages/playwright/src/common/configLoader.ts
+++ b/packages/playwright/src/common/configLoader.ts
@@ -378,11 +378,6 @@ export function restartWithExperimentalTsEsm(configFile: string | undefined, for
// Now check for the newer API presence.
if (!require('node:module').register) {
- // Older API is experimental, only supported on Node 16+.
- const nodeVersion = +process.versions.node.split('.')[0];
- if (nodeVersion < 16)
- return false;
-
// With older API requiring a process restart, do so conditionally on the config.
const configIsModule = !!configFile && fileIsModule(configFile);
if (!force && !configIsModule)
diff --git a/tests/config/browserTest.ts b/tests/config/browserTest.ts
index 6a178bbaf2..8e79da1f8e 100644
--- a/tests/config/browserTest.ts
+++ b/tests/config/browserTest.ts
@@ -36,6 +36,7 @@ export type BrowserTestWorkerFixtures = PageWorkerFixtures & {
browserType: BrowserType;
isAndroid: boolean;
isElectron: boolean;
+ nodeVersion: { major: number, minor: number, patch: number };
bidiTestSkipPredicate: (info: TestInfo) => boolean;
};
@@ -96,6 +97,11 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
await run(Number(browserVersion.split('.')[0]));
}, { scope: 'worker' }],
+ nodeVersion: [async ({}, use) => {
+ const [major, minor, patch] = process.versions.node.split('.');
+ await use({ major: +major, minor: +minor, patch: +patch });
+ }, { scope: 'worker' }],
+
isAndroid: [false, { scope: 'worker' }],
isElectron: [false, { scope: 'worker' }],
electronMajorVersion: [0, { scope: 'worker' }],
diff --git a/tests/library/browsercontext-fetch.spec.ts b/tests/library/browsercontext-fetch.spec.ts
index ae5cf5e7d5..abbc4f64a4 100644
--- a/tests/library/browsercontext-fetch.spec.ts
+++ b/tests/library/browsercontext-fetch.spec.ts
@@ -880,9 +880,9 @@ it('should respect timeout after redirects', async function({ context, server })
expect(error.message).toContain(`Request timed out after 100ms`);
});
-it('should not hang on a brotli encoded Range request', async ({ context, server }) => {
+it('should not hang on a brotli encoded Range request', async ({ context, server, nodeVersion }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/18190' });
- it.skip(+process.versions.node.split('.')[0] < 18);
+ it.skip(nodeVersion.major < 18);
const encodedRequestPayload = zlib.brotliCompressSync(Buffer.from('A'));
server.setRoute('/brotli', (req, res) => {
@@ -1094,10 +1094,9 @@ it('should support multipart/form-data and keep the order', async function({ con
expect(response.status()).toBe(200);
});
-it('should support repeating names in multipart/form-data', async function({ context, server }) {
+it('should support repeating names in multipart/form-data', async function({ context, server, nodeVersion }) {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28070' });
- const nodeVersion = +process.versions.node.split('.')[0];
- it.skip(nodeVersion < 20, 'File is not available in Node.js < 20. FormData is not available in Node.js < 18');
+ it.skip(nodeVersion.major < 20, 'File is not available in Node.js < 20. FormData is not available in Node.js < 18');
const postBodyPromise = new Promise<string>(resolve => {
server.setRoute('/empty.html', async (req, res) => {
resolve((await req.postBody).toString('utf-8'));
diff --git a/tests/library/browsercontext-storage-state.spec.ts b/tests/library/browsercontext-storage-state.spec.ts
index 02db42506d..d71657d1be 100644
--- a/tests/library/browsercontext-storage-state.spec.ts
+++ b/tests/library/browsercontext-storage-state.spec.ts
@@ -204,13 +204,13 @@ it('should handle missing file', async ({ contextFactory }, testInfo) => {
expect(error.message).toContain(`Error reading storage state from ${file}:\nENOENT`);
});
-it('should handle malformed file', async ({ contextFactory }, testInfo) => {
+it('should handle malformed file', async ({ contextFactory, nodeVersion }, testInfo) => {
const file = testInfo.outputPath('state.json');
fs.writeFileSync(file, 'not-json', 'utf-8');
const error = await contextFactory({
storageState: file,
}).catch(e => e);
- if (+process.versions.node.split('.')[0] > 18)
+ if (nodeVersion.major > 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`);
diff --git a/tests/library/browsertype-launch.spec.ts b/tests/library/browsertype-launch.spec.ts
index 011bc8a50d..75198f4f8b 100644
--- a/tests/library/browsertype-launch.spec.ts
+++ b/tests/library/browsertype-launch.spec.ts
@@ -130,9 +130,8 @@ it('should be callable twice', async ({ browserType }) => {
await browser.close();
});
-it('should allow await using', async ({ browserType }) => {
- const nodeVersion = +process.versions.node.split('.')[0];
- it.skip(nodeVersion < 18);
+it('should allow await using', async ({ browserType, nodeVersion }) => {
+ it.skip(nodeVersion.major < 18);
let b: Browser;
let c: BrowserContext;
diff --git a/tests/library/client-certificates.spec.ts b/tests/library/client-certificates.spec.ts
index 8e0a4cdf47..648fef0d75 100644
--- a/tests/library/client-certificates.spec.ts
+++ b/tests/library/client-certificates.spec.ts
@@ -727,9 +727,9 @@ test.describe('browser', () => {
await browser.close();
});
- test('should return target connection errors when using http2', async ({ browser, startCCServer, asset, browserName, isMac, isLinux }) => {
+ test('should return target connection errors when using http2', async ({ browser, startCCServer, asset, browserName, isMac, nodeVersion }) => {
test.skip(browserName === 'webkit' && isMac, 'WebKit on macOS does not proxy localhost');
- test.skip(+process.versions.node.split('.')[0] < 20, 'http2.performServerHandshake is not supported in older Node.js versions');
+ test.skip(nodeVersion.major < 20, 'http2.performServerHandshake is not supported in older Node.js versions');
const serverURL = await startCCServer({ http2: true });
const page = await browser.newPage({