Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Use vite preview port in templates for playwright config #5433

Merged
merged 9 commits into from
Jul 8, 2022
7 changes: 7 additions & 0 deletions .changeset/lemon-elephants-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'create-svelte': patch
'test-basics': patch
'@sveltejs/kit': patch
philip-weber marked this conversation as resolved.
Show resolved Hide resolved
---

Align `playwright` server ports with `vite` preview server port
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 3000
port: 4173
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const config = {
webServer: {
command: 'npm run build && npm run preview',
port: 3000
port: 4173
}
};

Expand Down
13 changes: 10 additions & 3 deletions packages/kit/test/apps/basics/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,10 @@ test.describe('Load', () => {
}
});

test('using window.fetch causes a warning', async ({ page, javaScriptEnabled }) => {
test.only('using window.fetch causes a warning', async ({ page, javaScriptEnabled }) => {
philip-weber marked this conversation as resolved.
Show resolved Hide resolved
const DEV_SERVER_PORT = 3000;
const PREVIEW_SERVER_PORT = 4173;
philip-weber marked this conversation as resolved.
Show resolved Hide resolved

if (javaScriptEnabled && process.env.DEV) {
const warnings = [];

Expand All @@ -1652,7 +1655,9 @@ test.describe('Load', () => {
expect(await page.textContent('h1')).toBe('42');

expect(warnings).toContain(
'Loading http://localhost:3000/load/window-fetch/data.json using `window.fetch`. For best results, use the `fetch` that is passed to your `load` function: https://kit.svelte.dev/docs/loading#input-fetch'
`Loading http://localhost:${
process.env.DEV ? DEV_SERVER_PORT : PREVIEW_SERVER_PORT
}/load/window-fetch/data.json using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/loading#input-fetch`
philip-weber marked this conversation as resolved.
Show resolved Hide resolved
);

warnings.length = 0;
Expand All @@ -1661,7 +1666,9 @@ test.describe('Load', () => {
expect(await page.textContent('h1')).toBe('42');

expect(warnings).not.toContain(
'Loading http://localhost:3000/load/window-fetch/data.json using `window.fetch`. For best results, use the `fetch` that is passed to your `load` function: https://kit.svelte.dev/docs/loading#input-fetch'
`Loading http://localhost:${
process.env.DEV ? DEV_SERVER_PORT : PREVIEW_SERVER_PORT
}/load/window-fetch/data.json using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/loading#input-fetch`
philip-weber marked this conversation as resolved.
Show resolved Hide resolved
);
}
});
Expand Down
8 changes: 2 additions & 6 deletions packages/kit/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,14 @@ if (!test_browser_device) {
);
}

const port = 3000;

/** @type {import('@playwright/test').PlaywrightTestConfig} */
export const config = {
forbidOnly: !!process.env.CI,
// generous timeouts on CI
timeout: process.env.CI ? 45000 : 15000,
webServer: {
command: process.env.DEV
? `npm run dev -- --port ${port}`
: `npm run build && npm run preview -- --port ${port}`,
port
command: process.env.DEV ? 'npm run dev' : 'npm run build && npm run preview',
port: process.env.DEV ? 3000 : 4173
},
retries: process.env.CI ? 5 : 0,
projects: [
Expand Down