Compare commits
3 Commits
7821b0198a
...
1a943465ec
| 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');
|
||||
}
|
||||
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) {
|
||||
throw new Error('PW_BASE_URL must be an HTTP(S) URL without credentials, query or hash');
|
||||
if (
|
||||
!['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 (target !== 'remote' && (baseURL.hostname !== '127.0.0.1' || baseURL.protocol !== 'http:' || baseURL.pathname !== '/')) {
|
||||
if (!baseURL.pathname.endsWith('/'))
|
||||
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>/');
|
||||
}
|
||||
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 = [
|
||||
['desktop', 1920, 1080],
|
||||
['mobile', 360, 800],
|
||||
];
|
||||
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({
|
||||
@@ -60,7 +84,12 @@ export default defineConfig({
|
||||
['html', { outputFolder: 'playwright-report', open: 'never' }],
|
||||
...(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: {
|
||||
baseURL: baseURL.href,
|
||||
headless,
|
||||
@@ -90,8 +119,12 @@ export default defineConfig({
|
||||
viewport: { width, height },
|
||||
},
|
||||
})),
|
||||
webServer: target === 'remote' ? undefined : {
|
||||
command: target === 'local-dist'
|
||||
webServer:
|
||||
target === 'remote'
|
||||
? undefined
|
||||
: {
|
||||
command:
|
||||
target === 'local-dist'
|
||||
? `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`,
|
||||
url: baseURL.href,
|
||||
|
||||
Reference in New Issue
Block a user