Skip to content

Commit

Permalink
feat(ct): https
Browse files Browse the repository at this point in the history
  • Loading branch information
sand4rt committed Dec 25, 2022
1 parent cce2921 commit 3ee833f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/playwright-test/src/plugins/vitePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down Expand Up @@ -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 () => {
Expand Down
3 changes: 2 additions & 1 deletion tests/components/ct-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"devDependencies": {
"typescript": "^4.7.4",
"vite": "^3.2.1",
"vite-plugin-solid": "^2.3.10"
"vite-plugin-mkcert": "^1.10.1",
"vite-plugin-solid": "^2.5.0"
},
"dependencies": {
"solid-js": "^1.4.7"
Expand Down
8 changes: 8 additions & 0 deletions tests/components/ct-solid/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-solid';
import solidPlugin from 'vite-plugin-solid';
import mkcert from'vite-plugin-mkcert';

const config: PlaywrightTestConfig = {
testDir: 'src',
Expand All @@ -23,6 +25,12 @@ const config: PlaywrightTestConfig = {
reporter: 'html',
use: {
trace: 'on-first-retry',
ctViteConfig: {
plugins: [mkcert(), solidPlugin()],
preview: {
https: true
}
}
},
projects: [
{
Expand Down
6 changes: 5 additions & 1 deletion tests/components/ct-solid/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import mkcert from'vite-plugin-mkcert';

export default defineConfig({
plugins: [solidPlugin()],
plugins: [mkcert(), solidPlugin()],
server: {
port: 3000,
},
preview: {
https: true
},
build: {
target: 'esnext',
},
Expand Down

0 comments on commit 3ee833f

Please sign in to comment.