Skip to content

Commit

Permalink
[fix] Use vite preview port in templates for playwright config (#5433)
Browse files Browse the repository at this point in the history
* [fix] Use vite preview port in playwright template

* Use `vite` ports for tests

* Add changeset

* Fix lint

* Update packages/kit/test/apps/basics/test/test.js

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update .changeset/lemon-elephants-chew.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update packages/kit/test/apps/basics/test/test.js

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* Update packages/kit/test/apps/basics/test/test.js

Co-authored-by: Rich Harris <hello@rich-harris.dev>

* on second thoughts, no changeset needed

Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
philip-weber and Rich-Harris committed Jul 8, 2022
1 parent a9cbb4c commit 6465aef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
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
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
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
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

0 comments on commit 6465aef

Please sign in to comment.