diff --git a/packages/playwright-test/src/plugins/vitePlugin.ts b/packages/playwright-test/src/plugins/vitePlugin.ts index ebad22e9418d5..67fb896b0ce1a 100644 --- a/packages/playwright-test/src/plugins/vitePlugin.ts +++ b/packages/playwright-test/src/plugins/vitePlugin.ts @@ -94,7 +94,7 @@ export function createPlugin( const sourcesDirty = !buildExists || hasNewComponents || await checkSources(buildInfo); viteConfig.root = rootDir; - viteConfig.preview = { port }; + viteConfig.preview = { port, ...viteConfig.preview }; viteConfig.build = { outDir }; @@ -152,9 +152,10 @@ export function createPlugin( stoppableServer = stoppable(previewServer.httpServer, 0); const isAddressInfo = (x: any): x is AddressInfo => x?.address; const address = previewServer.httpServer.address(); - if (isAddressInfo(address)) - process.env.PLAYWRIGHT_TEST_BASE_URL = `http://localhost:${address.port}`; - + if (isAddressInfo(address)) { + const protocol = viteConfig.preview.https ? 'https:' : 'http:'; + process.env.PLAYWRIGHT_TEST_BASE_URL = `${protocol}//localhost:${address.port}`; + } }, teardown: async () => { diff --git a/tests/components/ct-solid/vite.config.ts b/tests/components/ct-solid/vite.config.ts index 9ff59a172211a..d9f0f6baa718e 100644 --- a/tests/components/ct-solid/vite.config.ts +++ b/tests/components/ct-solid/vite.config.ts @@ -1,6 +1,5 @@ import { defineConfig } from 'vite'; import solidPlugin from 'vite-plugin-solid'; - export default defineConfig({ plugins: [solidPlugin()], server: {