Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(ct): use stoppable server (#16329)
Pavel Feldmana2e05bb41986
diff --git a/packages/playwright-test/ThirdPartyNotices.txt b/packages/playwright-test/ThirdPartyNotices.txtindex b6649ae4b1..7f4514d451 100644--- a/packages/playwright-test/ThirdPartyNotices.txt+++ b/packages/playwright-test/ThirdPartyNotices.txt@@ -137,6 +137,7 @@ This project incorporates components from the projects listed below. The origina- [email protected] (https://github.com/evanw/node-source-map-support)- [email protected] (https://github.com/mozilla/source-map)- [email protected] (https://github.com/tapjs/stack-utils)+- [email protected] (https://github.com/hunterloftis/stoppable)- [email protected] (https://github.com/chalk/supports-color)- [email protected] (https://github.com/chalk/supports-color)- [email protected] (https://github.com/sindresorhus/to-fast-properties)@@ -3931,6 +3932,32 @@ THE SOFTWARE.=========================================END OF [email protected] AND INFORMATION+%% [email protected] NOTICES AND INFORMATION BEGIN HERE+=========================================+The MIT License (MIT)++Copyright (c) 2017 Hunter Loftis <[email protected]>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+=========================================+END OF [email protected] AND INFORMATION+%% [email protected] NOTICES AND INFORMATION BEGIN HERE=========================================MIT License@@ -4002,6 +4029,6 @@ END OF [email protected] AND INFORMATIONSUMMARY BEGIN HERE=========================================-Total Packages: 137+Total Packages: 138=========================================END OF SUMMARY\ No newline at end of filediff --git a/packages/playwright-test/bundles/utils/package-lock.json b/packages/playwright-test/bundles/utils/package-lock.jsonindex 5fc800942b..09fd67cffd 100644--- a/packages/playwright-test/bundles/utils/package-lock.json+++ b/packages/playwright-test/bundles/utils/package-lock.json@@ -11,12 +11,20 @@"json5": "2.2.1","open": "8.4.0","pirates": "4.0.4",- "source-map-support": "0.5.21"+ "source-map-support": "0.5.21",+ "stoppable": "^1.1.0"},"devDependencies": {- "@types/source-map-support": "^0.5.4"+ "@types/source-map-support": "^0.5.4",+ "@types/stoppable": "^1.1.1"}},+ "node_modules/@types/node": {+ "version": "18.6.4",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.4.tgz",+ "integrity": "sha512-I4BD3L+6AWiUobfxZ49DlU43gtI+FTHSv9pE2Zekg6KjMpre4ByusaljW3vYSLJrvQ1ck1hUaeVu8HVlY3vzHg==",+ "dev": true+ },"node_modules/@types/source-map-support": {"version": "0.5.4","resolved": "https://registry.npmjs.org/@types/source-map-support/-/source-map-support-0.5.4.tgz",@@ -26,6 +34,15 @@"source-map": "^0.6.0"}},+ "node_modules/@types/stoppable": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/@types/stoppable/-/stoppable-1.1.1.tgz",+ "integrity": "sha512-b8N+fCADRIYYrGZOcmOR8ZNBOqhktWTB/bMUl5LvGtT201QKJZOOH5UsFyI3qtteM6ZAJbJqZoBcLqqxKIwjhw==",+ "dev": true,+ "dependencies": {+ "@types/node": "*"+ }+ },"node_modules/buffer-from": {"version": "1.1.2","resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",@@ -115,9 +132,24 @@"buffer-from": "^1.0.0","source-map": "^0.6.0"}+ },+ "node_modules/stoppable": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz",+ "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==",+ "engines": {+ "node": ">=4",+ "npm": ">=6"+ }}},"dependencies": {+ "@types/node": {+ "version": "18.6.4",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.4.tgz",+ "integrity": "sha512-I4BD3L+6AWiUobfxZ49DlU43gtI+FTHSv9pE2Zekg6KjMpre4ByusaljW3vYSLJrvQ1ck1hUaeVu8HVlY3vzHg==",+ "dev": true+ },"@types/source-map-support": {"version": "0.5.4","resolved": "https://registry.npmjs.org/@types/source-map-support/-/source-map-support-0.5.4.tgz",@@ -127,6 +159,15 @@"source-map": "^0.6.0"}},+ "@types/stoppable": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/@types/stoppable/-/stoppable-1.1.1.tgz",+ "integrity": "sha512-b8N+fCADRIYYrGZOcmOR8ZNBOqhktWTB/bMUl5LvGtT201QKJZOOH5UsFyI3qtteM6ZAJbJqZoBcLqqxKIwjhw==",+ "dev": true,+ "requires": {+ "@types/node": "*"+ }+ },"buffer-from": {"version": "1.1.2","resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",@@ -183,6 +224,11 @@"buffer-from": "^1.0.0","source-map": "^0.6.0"}+ },+ "stoppable": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz",+ "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw=="}}}diff --git a/packages/playwright-test/bundles/utils/package.json b/packages/playwright-test/bundles/utils/package.jsonindex d35bedfa8b..2501ea53a6 100644--- a/packages/playwright-test/bundles/utils/package.json+++ b/packages/playwright-test/bundles/utils/package.json@@ -12,9 +12,11 @@"json5": "2.2.1","open": "8.4.0","pirates": "4.0.4",- "source-map-support": "0.5.21"+ "source-map-support": "0.5.21",+ "stoppable": "^1.1.0"},"devDependencies": {- "@types/source-map-support": "^0.5.4"+ "@types/source-map-support": "^0.5.4",+ "@types/stoppable": "^1.1.1"}}diff --git a/packages/playwright-test/bundles/utils/src/utilsBundleImpl.ts b/packages/playwright-test/bundles/utils/src/utilsBundleImpl.tsindex aed02ee179..52a4b0fd8c 100644--- a/packages/playwright-test/bundles/utils/src/utilsBundleImpl.ts+++ b/packages/playwright-test/bundles/utils/src/utilsBundleImpl.ts@@ -25,3 +25,6 @@ export const pirates = piratesLibrary;import sourceMapSupportLibrary from 'source-map-support';export const sourceMapSupport = sourceMapSupportLibrary;++import stoppableLibrary from 'stoppable';+export const stoppable = stoppableLibrary;diff --git a/packages/playwright-test/src/plugins/vitePlugin.ts b/packages/playwright-test/src/plugins/vitePlugin.tsindex ce8a607ea0..afaf313dc4 100644--- a/packages/playwright-test/src/plugins/vitePlugin.ts+++ b/packages/playwright-test/src/plugins/vitePlugin.ts@@ -17,16 +17,17 @@import fs from 'fs';import type { Suite } from '../../types/testReporter';import path from 'path';-import type { InlineConfig, Plugin, PreviewServer } from 'vite';+import type { InlineConfig, Plugin } from 'vite';import type { TestRunnerPlugin } from '.';import { parse, traverse, types as t } from '../babelBundle';+import { stoppable } from '../utilsBundle';import type { ComponentInfo } from '../tsxTransform';import { collectComponentUsages, componentInfo } from '../tsxTransform';import type { FullConfig } from '../types';import { assert, calculateSha1 } from 'playwright-core/lib/utils';import type { AddressInfo } from 'net';-let previewServer: PreviewServer;+let stoppableServer: any;const VERSION = 6;type CtConfig = {@@ -135,7 +136,8 @@ export function createPlugin(}if (hasNewTests || hasNewComponents || sourcesDirty)await fs.promises.writeFile(buildInfoFile, JSON.stringify(buildInfo, undefined, 2));- previewServer = await preview(viteConfig);+ const previewServer = await preview(viteConfig);+ stoppableServer = stoppable(previewServer.httpServer, 0);const isAddressInfo = (x: any): x is AddressInfo => x?.address;const address = previewServer.httpServer.address();if (isAddressInfo(address))@@ -143,12 +145,7 @@ export function createPlugin(},teardown: async () => {- await new Promise<void>((f, r) => previewServer.httpServer.close(err => {- if (err)- r(err);- else- f();- }));+ await new Promise(f => stoppableServer.stop(f));},};}diff --git a/packages/playwright-test/src/utilsBundle.ts b/packages/playwright-test/src/utilsBundle.tsindex 780bc4fe33..4e8ecf3909 100644--- a/packages/playwright-test/src/utilsBundle.ts+++ b/packages/playwright-test/src/utilsBundle.ts@@ -18,3 +18,4 @@ export const json5: typeof import('../bundles/utils/node_modules/json5') = requiexport const open: typeof import('../bundles/utils/node_modules/open') = require('./utilsBundleImpl').open;export const pirates: typeof import('../bundles/utils/node_modules/pirates') = require('./utilsBundleImpl').pirates;export const sourceMapSupport: typeof import('../bundles/utils/node_modules/@types/source-map-support') = require('./utilsBundleImpl').sourceMapSupport;+export const stoppable: typeof import('../bundles/utils/node_modules/@types/stoppable') = require('./utilsBundleImpl').stoppable;