Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a943465ec | |||
| 1ca241ee57 | |||
| b80afd273c |
+42
-9
@@ -27,21 +27,45 @@ if (target === 'remote' && !process.env.PW_BASE_URL) {
|
|||||||
throw new Error('PW_BASE_URL is required for remote tests');
|
throw new Error('PW_BASE_URL is required for remote tests');
|
||||||
}
|
}
|
||||||
const baseURL = new URL(process.env.PW_BASE_URL || 'http://127.0.0.1:4175/');
|
const baseURL = new URL(process.env.PW_BASE_URL || 'http://127.0.0.1:4175/');
|
||||||
if (!['http:', 'https:'].includes(baseURL.protocol) || baseURL.username || baseURL.password || baseURL.search || baseURL.hash) {
|
if (
|
||||||
throw new Error('PW_BASE_URL must be an HTTP(S) URL without credentials, query or hash');
|
!['http:', 'https:'].includes(baseURL.protocol) ||
|
||||||
|
baseURL.username ||
|
||||||
|
baseURL.password ||
|
||||||
|
baseURL.search ||
|
||||||
|
baseURL.hash
|
||||||
|
) {
|
||||||
|
throw new Error(
|
||||||
|
'PW_BASE_URL must be an HTTP(S) URL without credentials, query or hash',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!baseURL.pathname.endsWith('/')) throw new Error('PW_BASE_URL directory path must end with /');
|
if (!baseURL.pathname.endsWith('/'))
|
||||||
if (target !== 'remote' && (baseURL.hostname !== '127.0.0.1' || baseURL.protocol !== 'http:' || baseURL.pathname !== '/')) {
|
throw new Error('PW_BASE_URL directory path must end with /');
|
||||||
|
if (
|
||||||
|
target !== 'remote' &&
|
||||||
|
(baseURL.hostname !== '127.0.0.1' ||
|
||||||
|
baseURL.protocol !== 'http:' ||
|
||||||
|
baseURL.pathname !== '/')
|
||||||
|
) {
|
||||||
throw new Error('Local targets require http://127.0.0.1:<port>/');
|
throw new Error('Local targets require http://127.0.0.1:<port>/');
|
||||||
}
|
}
|
||||||
const isCI = Boolean(process.env.CI && process.env.CI !== 'false');
|
const isCI = Boolean(process.env.CI && process.env.CI !== 'false');
|
||||||
const headless = process.env.PW_HEADLESS === undefined ? isCI : process.env.PW_HEADLESS === '1';
|
const headless =
|
||||||
|
process.env.PW_HEADLESS === undefined
|
||||||
|
? isCI
|
||||||
|
: process.env.PW_HEADLESS === '1';
|
||||||
const viewports = [
|
const viewports = [
|
||||||
['desktop', 1920, 1080],
|
['desktop', 1920, 1080],
|
||||||
['mobile', 360, 800],
|
['mobile', 360, 800],
|
||||||
];
|
];
|
||||||
if (process.env.PW_EXTENDED_LAYOUT === '1') {
|
if (process.env.PW_EXTENDED_LAYOUT === '1') {
|
||||||
viewports.push(['tablet', 768, 1024], ['desktop-boundary', 1024, 768], ['laptop-hd', 1366, 768], ['laptop-wxga', 1440, 900], ['qhd', 2560, 1440], ['uhd', 3840, 2160]);
|
viewports.push(
|
||||||
|
['tablet', 768, 1024],
|
||||||
|
['desktop-boundary', 1024, 768],
|
||||||
|
['laptop-hd', 1366, 768],
|
||||||
|
['laptop-wxga', 1440, 900],
|
||||||
|
['qhd', 2560, 1440],
|
||||||
|
['uhd', 3840, 2160],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@@ -60,7 +84,12 @@ export default defineConfig({
|
|||||||
['html', { outputFolder: 'playwright-report', open: 'never' }],
|
['html', { outputFolder: 'playwright-report', open: 'never' }],
|
||||||
...(isCI ? [['junit', { outputFile: 'test-results/junit.xml' }]] : []),
|
...(isCI ? [['junit', { outputFile: 'test-results/junit.xml' }]] : []),
|
||||||
],
|
],
|
||||||
metadata: { platform: process.platform, node: process.version, target, baseURL: baseURL.href },
|
metadata: {
|
||||||
|
platform: process.platform,
|
||||||
|
node: process.version,
|
||||||
|
target,
|
||||||
|
baseURL: baseURL.href,
|
||||||
|
},
|
||||||
use: {
|
use: {
|
||||||
baseURL: baseURL.href,
|
baseURL: baseURL.href,
|
||||||
headless,
|
headless,
|
||||||
@@ -90,8 +119,12 @@ export default defineConfig({
|
|||||||
viewport: { width, height },
|
viewport: { width, height },
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
webServer: target === 'remote' ? undefined : {
|
webServer:
|
||||||
command: target === 'local-dist'
|
target === 'remote'
|
||||||
|
? undefined
|
||||||
|
: {
|
||||||
|
command:
|
||||||
|
target === 'local-dist'
|
||||||
? `npm run preview -- --host 127.0.0.1 --port ${baseURL.port || 80}`
|
? `npm run preview -- --host 127.0.0.1 --port ${baseURL.port || 80}`
|
||||||
: `npm run dev -- --host 127.0.0.1 --port ${baseURL.port || 80} --strictPort`,
|
: `npm run dev -- --host 127.0.0.1 --port ${baseURL.port || 80} --strictPort`,
|
||||||
url: baseURL.href,
|
url: baseURL.href,
|
||||||
|
|||||||
Reference in New Issue
Block a user