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
5 changes: 5 additions & 0 deletions .changeset/lemon-elephants-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

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
6 changes: 4 additions & 2 deletions packages/kit/test/apps/basics/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,8 @@ test.describe('Load', () => {
});

test('using window.fetch causes a warning', async ({ page, javaScriptEnabled }) => {
const port = process.env.DEV ? 3000 : 4173;

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

Expand All @@ -1652,7 +1654,7 @@ 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:${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`
);

warnings.length = 0;
Expand All @@ -1661,7 +1663,7 @@ 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:${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`
);
}
});
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