@playwright/test#PlaywrightTestConfig TypeScript Examples
The following examples show how to use
@playwright/test#PlaywrightTestConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: playwright.config.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
config: PlaywrightTestConfig = {
globalSetup: require.resolve("./tests/global-setup"),
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
// Limit the number of workers on CI, use default locally
workers: process.env.CI ? 3 : undefined,
use: {
trace: "on-first-retry",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
],
}
Example #2
Source File: playwright.config.ts From excalideck with MIT License | 6 votes |
config: PlaywrightTestConfig = {
testDir: "test/scenario",
forbidOnly: IS_CI,
retries: IS_CI ? 4 : 0,
webServer: {
command: "yarn start",
port: 1234,
env: {
EXCALIDRAW_ELEMENTS_INPUT_ONCHANGE_CHECK_INTERVAL: "1",
SLIDE_MINIATURES_DROP_TRANSITION_DURATION: "0",
SORTABLE_SLIDE_MINIATURE_MOVE_TRANSITION_DURATION: "0",
SLIDE_MINIATURE_IMAGE_RENDER_DEBOUNCE: "1",
},
},
use: {
trace: "retain-on-failure",
},
reporter: IS_CI ? [["github"], ["list"]] : "list",
projects: compact([
{
name: "chromium",
use: { browserName: "chromium" },
},
{
name: "firefox",
use: { browserName: "firefox" },
},
// Re-enable when @playwright/test v1.17.0 is released. See
// microsoft/playwright issue #9811
platform() !== "darwin"
? {
name: "webkit",
use: { browserName: "webkit" },
}
: null,
]),
}
Example #3
Source File: playwright.config.ts From jupyterlab-unfold with BSD 3-Clause "New" or "Revised" License | 6 votes |
config: PlaywrightTestConfig = {
timeout: 20000,
use: {
// Browser options
// headless: false,
launchOptions: {
slowMo: 400,
},
// Context options
viewport: { width: 1280, height: 720 },
// Artifacts
video: 'on',
},
}
Example #4
Source File: playwright.config.ts From mirrorz with MIT License | 6 votes |
config: PlaywrightTestConfig = {
use: {
headless: true,
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
},
projects: [
{
name: 'Chromium',
use: {
browserName: 'chromium',
},
},
{
name: 'Firefox',
use: { browserName: 'firefox' },
},
{
name: 'WebKit',
use: { browserName: 'webkit' },
},
],
}
Example #5
Source File: playwright.config.ts From mui-toolpad with MIT License | 6 votes |
config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
use: {
trace: 'on-first-retry',
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || 'http://localhost:3000/',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
],
}
Example #6
Source File: playwright.config.ts From vanilla-extract with MIT License | 6 votes |
config: PlaywrightTestConfig = {
testMatch: '**/*.playwright.ts',
updateSnapshots: 'none',
expect: {
toMatchSnapshot: {
threshold: 0.2,
},
},
projects: [
{
name: 'Desktop - Chromium',
use: {
browserName: 'chromium',
channel: 'chrome',
viewport: {
width: 1200,
height: 1080,
},
},
},
{
name: 'Mobile - Chromium',
use: {
browserName: 'chromium',
channel: 'chrome',
viewport: {
width: 414,
height: 896,
},
},
},
],
}
Example #7
Source File: playwright.config.ts From reskript with MIT License | 5 votes |
config: PlaywrightTestConfig = {
workers: 1,
testMatch: 'e2e/*.test.ts',
}
Example #8
Source File: playwright.config.ts From erda-ui with GNU Affero General Public License v3.0 | 5 votes |
config: PlaywrightTestConfig<{ version: string }> = {
// Look for test files in the "tests" directory, relative to this configuration file
testDir: 'tests',
testMatch: '**/*.spec.ts',
outputDir: 'results', // under tests
preserveOutput: 'always',
// Each test is given 30 seconds
timeout: 30000,
// Forbid test.only on CI
forbidOnly: !!process.env.CI,
// Two retries for each test
retries: 2,
// Limit the number of workers on CI, use default locally
workers: process.env.CI ? 2 : undefined,
globalSetup: './global-setup',
use: {
// Browser options
headless: !!process.env.CI,
slowMo: 50,
locale: 'en-GB',
// Context options
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
// Artifacts
screenshot: 'on',
video: 'retry-with-video',
},
projects: [
{
name: 'all',
testMatch: '**/*.spec.ts',
use: {
// version: '1.1'
},
},
{
name: 'admin',
testMatch: 'admin/*.spec.ts',
use: {
// version: '1.1'
},
},
{
name: 'dop',
testMatch: 'dop/*.spec.ts',
use: {},
},
{
name: 'cmp',
testMatch: 'cmp/*.spec.ts',
use: {},
},
],
}
Example #9
Source File: playwright.config.ts From tailchat with GNU General Public License v3.0 | 4 votes |
config: PlaywrightTestConfig = {
testDir: './tests',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
// reporter: 'html',
reporter: 'line',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL: 'http://localhost:11011',
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: process.env.CI ? 'on-first-retry' : 'retain-on-failure',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
},
},
{
name: 'webkit',
use: {
...devices['Desktop Safari'],
},
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: {
// ...devices['iPhone 12'],
// },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
],
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// port: 3000,
// },
}