forked from momentum-design/momentum-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(pixelperfect): pixel perfect on visual regression (momentum-desi…
…gn#884) * feat: show playwright test report * temp change in test file * temporary fix to compression * temporary change in test file * added download artifact, job summary to test * no message * no message * no message * no message * no message * no message * Possible fix * Minor fix * Added temp tests * test(pixelperfect): test screenshots on firefox * test(pixelperfect): use docker to handle e2e test * test(pixelperfect): support all browser and add docker to workflow * test(pixelperfect): update readme doc * test(pixelperfect): update snapshot * test(pixelperfect): update webkit snapshot * test(pixelperfect): update themeprovider snapshot * Update package.json * test(pixelperfect): address comments * Update text.e2e-test.ts * Update themeprovider.e2e-test.ts * revert: remove github action change * ci: run test:e2e:docker:all as postbuild * test(pixelperfect): update snapshot * test(pixelperfect): update testing * test(pixelperfect): update docker testing * test(pixelperfect): update snapshot changes for text component * test(pixelperfect): testing for ghrc credential * test(pixelperfect): update pull-request yml * fix(pixelperfect): update port changes * fix(pixelperfect): fix ci issue * test(pixelperfect): update * test(pixelperfect): update * test(pixelperfect): fix port issue * docs: added to testing markdown * docs: small fix i overlooked * test(pixelperfect): update script --------- Co-authored-by: Deeya <dishuupadhyay01@gmail.com> Co-authored-by: Jason Chai Jing <jachai@cisco.com> Co-authored-by: Christoph Scheffauer <scheffauerc@gmail.com>
- Loading branch information
1 parent
f26e522
commit e0fee19
Showing
207 changed files
with
342 additions
and
65 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
133 changes: 133 additions & 0 deletions
133
packages/components/config/playwright/docker/playwright.docker.config.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,133 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
import type { GitHubActionOptions } from '@estruyf/github-actions-reporter'; | ||
import { devices } from '@playwright/test'; | ||
import os from 'os'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
let url; | ||
if (os.platform() === 'linux') { | ||
url = 'http://172.17.0.1:4000'; | ||
} else { | ||
url = 'http://host.docker.internal:4000'; | ||
} | ||
|
||
const githubActionsReporterOptions: GitHubActionOptions = { | ||
title: 'Playwright E2E Test results', | ||
useDetails: true, | ||
showAnnotations: true, | ||
showTags: true, | ||
showError: true, | ||
includeResults: ['fail', 'flaky'], | ||
}; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
const config: PlaywrightTestConfig = { | ||
testDir: '../../../src', | ||
testMatch: /.*\.e2e-test\.ts/, | ||
/* 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, | ||
}, | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* 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 ? '50%' : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: process.env.CI ? [['html'], ['@estruyf/github-actions-reporter', githubActionsReporterOptions]] : 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ | ||
actionTimeout: 0, | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: url, | ||
/* On CI: Collect trace when retrying the failed test / | ||
Locally: always collect trace. See https://playwright.dev/docs/trace-viewer */ | ||
trace: process.env.CI ? 'retain-on-failure' : 'on', | ||
}, | ||
|
||
snapshotPathTemplate: '{testDir}/{testFileDir}/__screenshots__/{projectName}/{arg}{ext}', | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chrome', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
channel: '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: 'msedge', | ||
use: { | ||
channel: 'msedge', | ||
}, | ||
}, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: [ | ||
{ | ||
command: 'yarn test:e2e:setup', | ||
url: 'http://localhost:4000', | ||
stdout: 'pipe', | ||
stderr: 'pipe', | ||
timeout: 240 * 1000, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
{ | ||
command: 'yarn test:e2e:docker:run', | ||
url: 'http://localhost:3000', | ||
stdout: 'pipe', | ||
stderr: 'pipe', | ||
timeout: 240 * 1000, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
], | ||
}; | ||
|
||
export default config; |
11 changes: 11 additions & 0 deletions
11
packages/components/config/playwright/docker/utils/Dockerfile.test.postbuild
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,11 @@ | ||
FROM mcr.microsoft.com/playwright:v1.47.2-focal | ||
|
||
RUN npm install -g playwright@1.47.2 | ||
|
||
RUN npx playwright install | ||
|
||
RUN npx playwright install chrome | ||
|
||
RUN npx playwright install msedge | ||
|
||
CMD ["npx", "playwright", "run-server", "--port", "3000", "--host", "0.0.0.0"] |
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
Oops, something went wrong.