import { defineConfig, devices } from '@playwright/test';
import os from 'os';
import * as path from 'path';
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
* See https://playwright.dev/docs/test-configuration.
*/
const isCI = !!process.env.CI;
const getProfilerServerCmd = (port = 9000) => {
const platform = os.platform();
let serverBinDir = '../server/output/';
let profilerServer = 'profiler_server';
let logPath = path.resolve(__dirname, 'log/');
if (platform === 'win32') {
serverBinDir = path.join(__dirname, serverBinDir, 'win_mingw64/bin/');
profilerServer += '.exe';
logPath = 'C:\\msinsight-log';
} else if (platform === 'darwin') {
serverBinDir += 'darwin/bin/';
} else if (platform === 'linux') {
const arch = os.arch() === 'x64' ? 'x86_64' : 'aarch64';
serverBinDir += `linux-${arch}/bin/`;
} else {
throw new Error(`Unsupported platform: ${platform}`);
}
return `${serverBinDir}${profilerServer} --wsPort=${port} --logPath=${logPath}`;
};
export default defineConfig({
testDir: './src/tests',
timeout: 60 * 1000,
expect: {
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
forbidOnly: !!process.env.CI,
retries: 0,
workers: process.env.CI ? 1 : 1,
reporter: [
['html', { open: 'never' }],
[path.resolve(__dirname, 'src/utils/myReporter.ts')],
],
use: {
actionTimeout: 0,
baseURL: 'http://localhost:5174',
trace: 'on-first-retry',
headless: true,
launchOptions: {
args: [
'--use-gl=swiftshader',
'--disable-gpu-compositing',
'--disable-webgl',
],
},
},
projects: [
{
use: {
...devices['Desktop Chrome'],
viewport: { width: 1920, height: 1080 },
},
},
],
webServer: [
{
command: getProfilerServerCmd(9000),
reuseExistingServer: !isCI,
},
{
* Use the dev server by default for faster feedback loop.
* Use the preview server on CI for more realistic testing.
* Playwright will re-use the local server if there is already a dev-server running.
*/
command: 'npm run staging',
cwd: path.resolve(__dirname, '../modules/framework'),
url: 'http://127.0.0.1:5174',
reuseExistingServer: !isCI,
},
],
});