-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update E2E performance tests to run just from the NPM script
- Loading branch information
1 parent
916fa01
commit 15a70ba
Showing
4 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
import { config } from 'dotenv'; | ||
import path from 'path'; | ||
|
||
config( { path: path.resolve( __dirname, '../e2e/config', '.env' ) } ); | ||
config( { path: path.resolve( __dirname, '../e2e/config', 'local.env' ) } ); | ||
|
||
const { BASE_URL, NODE_ENV } = process.env; | ||
|
||
const getBaseUrl = () => { | ||
if ( NODE_ENV === 'atomic' ) { | ||
return 'https://wcpaytestecomm.wpcomstaging.com/'; | ||
} | ||
|
||
return BASE_URL ?? 'http://localhost:8084'; | ||
}; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig( { | ||
testDir: './specs/', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: false, | ||
/* 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. */ | ||
workers: 1, | ||
/* Reporters to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: process.env.CI | ||
? [ | ||
/* If running on CI, include the dot reporter and JSON reporter. */ | ||
[ 'dot' ], | ||
[ 'json', { outputFile: 'results.json' } ], | ||
[ 'html' ], | ||
] | ||
: [ [ 'html', { open: 'never' } ] ], | ||
outputDir: './test-results', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
baseURL: getBaseUrl(), | ||
screenshot: 'only-on-failure', | ||
trace: 'retain-on-failure', | ||
video: 'on-first-retry', | ||
viewport: { width: 1280, height: 720 }, | ||
}, | ||
timeout: 120 * 1000, // Default is 30s, sometimes it is not enough for local tests due to long setup. | ||
expect: { | ||
toHaveScreenshot: { | ||
maxDiffPixelRatio: | ||
process.env.E2E_WC_VERSION === '7.7.0' ? 0.035 : 0.025, | ||
}, | ||
//=* Increase expect timeout to 10 seconds. See https://playwright.dev/docs/test-timeouts#set-expect-timeout-in-the-config.*/ | ||
timeout: 20 * 1000, | ||
}, | ||
snapshotPathTemplate: '{testDir}/__snapshots__/{testFilePath}/{arg}{ext}', | ||
|
||
testMatch: /specs\/performance/, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'basic', | ||
use: { ...devices[ 'Desktop Chrome' ] }, | ||
testMatch: /basic.spec.ts/, | ||
dependencies: [ 'setup' ], | ||
}, | ||
{ | ||
name: 'chromium', | ||
use: { ...devices[ 'Desktop Chrome' ] }, | ||
dependencies: [ 'setup' ], | ||
}, | ||
// Setup project | ||
{ name: 'setup', testMatch: /.*\.setup\.ts/ }, | ||
], | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "🎭 Running Playwright e2e tests in default headless mode, skipping @todo."; | ||
|
||
docker compose -f ./tests/e2e/docker-compose.yml run --rm -it --service-ports playwright \ | ||
npx playwright test --config=tests/e2e/playwright.performance.config.ts --grep-invert @todo "$@" |