cal.pub0.org/tests/config/playwright.config.ts

74 lines
2.2 KiB
TypeScript
Raw Permalink Normal View History

2022-05-11 03:51:24 +00:00
import { devices, PlaywrightTestConfig } from "@playwright/test";
import { addAliases } from "module-alias";
2022-05-11 16:46:52 +00:00
import * as os from "os";
import * as path from "path";
// Add aliases for the paths specified in the tsconfig.json file.
// This is needed because playwright does not consider tsconfig.json
// For more info, see:
// https://stackoverflow.com/questions/69023682/typescript-playwright-error-cannot-find-module
// https://github.com/microsoft/playwright/issues/7066#issuecomment-983984496
addAliases({
"@components": __dirname + "/apps/web/components",
"@lib": __dirname + "/apps/web/lib",
"@server": __dirname + "/apps/web/server",
"@ee": __dirname + "/apps/web/ee",
});
2022-05-14 03:02:10 +00:00
require("dotenv").config({ path: "../../.env" });
const outputDir = path.join(__dirname, "..", "..", "test-results");
const testDir = path.join(__dirname, "..", "..", "apps/web/playwright");
2022-05-12 14:16:27 +00:00
const DEFAULT_NAVIGATION_TIMEOUT = 15000;
2022-05-11 03:51:24 +00:00
2022-05-11 16:46:52 +00:00
const headless = !!process.env.CI || !!process.env.PLAYWRIGHT_HEADLESS;
const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
retries: 1,
2022-05-11 16:46:52 +00:00
workers: os.cpus().length,
timeout: 60_000,
2022-05-12 14:16:27 +00:00
maxFailures: headless ? 10 : undefined,
reporter: [
[process.env.CI ? "github" : "list"],
2022-05-18 16:54:36 +00:00
["html", { outputFolder: path.join(outputDir, "reports/playwright-html-report"), open: "never" }],
["junit", { outputFile: path.join(outputDir, "reports/results.xml") }],
],
globalSetup: require.resolve("./globalSetup"),
outputDir,
webServer: {
command: "NEXT_PUBLIC_IS_E2E=1 yarn workspace @calcom/web start -p 3000",
port: 3000,
timeout: 60_000,
reuseExistingServer: !process.env.CI,
},
use: {
2022-05-11 16:46:52 +00:00
baseURL: "http://localhost:3000/",
locale: "en-US",
trace: "retain-on-failure",
2022-05-11 16:46:52 +00:00
headless,
},
projects: [
{
name: "chromium",
testDir,
2022-05-11 03:51:24 +00:00
use: {
...devices["Desktop Chrome"],
/** If navigation takes more than this, then something's wrong, let's fail fast. */
navigationTimeout: DEFAULT_NAVIGATION_TIMEOUT,
},
},
/* {
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
}, */
],
};
export default config;