-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from launchableinc/playwright
Add playwright example
- Loading branch information
Showing
9 changed files
with
794 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: playwright | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
paths: | ||
- "playwright/**" | ||
pull_request: | ||
paths: | ||
- "playwright/**" | ||
|
||
env: | ||
LAUNCHABLE_TOKEN: ${{ secrets.LAUNCHABLE_TOKEN_PLAYWRIGHT }} | ||
LAUNCHABLE_DEBUG: 1 | ||
LAUNCHABLE_REPORT_ERROR: 1 | ||
|
||
jobs: | ||
tests: | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
working-directory: playwright | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
browser: [chromium, firefox, webkit] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# for setup launchable command | ||
- uses: actions/setup-python@v5 | ||
- name: Set up JDK 1.8 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 8 | ||
distribution: 'temurin' | ||
- name: Install launchable CLI | ||
run: | | ||
pip install git+https://github.com/launchableinc/cli.git@playwright | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- name: Set up playwright | ||
run: | | ||
npm ci | ||
npx playwright install --with-deps | ||
- name: Record commits and build | ||
run: 'launchable record build --name "$GITHUB_RUN_ID" --source ..' # care for working-directory path | ||
- name: Subset | ||
run: find tests/*.ts | launchable subset --confidence 80% --flavor browser=${{ matrix.browser }} playwright > launchable-subset.txt | ||
- name: Run Playwright tests | ||
run: npm run test --project=${{ matrix.browser }} $(cat launchable-subset.txt) | ||
- name: Record | ||
run: launchable record tests playwright report.xml | ||
if: always() |
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,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
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,46 @@ | ||
# rocket-car-playwright | ||
|
||
## Recording test results | ||
|
||
```sh | ||
$ playwright test --reporter=junit > report.xml | ||
|
||
$ BUILD_NAME=test | ||
$ launchable record build --name ${BUILD_NAME} --source .. | ||
| Name | Path | HEAD Commit | | ||
|--------|--------|------------------------------------------| | ||
| . | . | e4303d272680af330f96d5ff997ea116a3553cbb | | ||
|
||
$ launchable record tests --build ${BUILD_NAME} playwright report.xml | ||
|
||
Launchable recorded tests for build 7720923648 (test session 2575438) to workspace launchableinc/rocket-car-playwright from 1 files: | ||
|
||
| Files found | Tests found | Tests passed | Tests failed | Total duration (min) | | ||
|---------------|---------------|----------------|----------------|------------------------| | ||
| 1 | 26 | 25 | 1 | 0.42 | | ||
|
||
Visit https://app.launchableinc.com/organizations/launchableinc/workspaces/rocket-car-playwright/test-sessions/2575438 to view uploaded test results (or run `launchable inspect tests --test-session-id 2575438`) | ||
``` | ||
|
||
## Subsetting your test runs | ||
|
||
```sh | ||
$ BUILD_NAME=test | ||
$ CONFIDENCE="90%" | ||
|
||
$ find ./tests/*.ts | sed -e 's/.\/tests\///' | launchable subset --confidence ${CONFIDENCE} playwright > launchable-subset.txt | ||
|
||
Your model is currently in training | ||
Launchable created subset 751189 for build 7720923648 (test session 2575438) in workspace launchableinc/rocket-car-playwright | ||
|
||
| | Candidates | Estimated duration (%) | Estimated duration (min) | | ||
|-----------|--------------|--------------------------|----------------------------| | ||
| Subset | 2 | 100.00 | 0.00 | | ||
| Remainder | 0 | 0.00 | 0.00 | | ||
| | | | | | ||
| Total | 2 | 100.00 | 0.00 | | ||
|
||
Run `launchable inspect subset --subset-id 751189` to view full subset details | ||
|
||
$ playwright test ./tests/$(cat launchable-subset.txt) --reporter=junit > report.xml | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,16 @@ | ||
{ | ||
"name": "playwright", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "playwright test" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@playwright/test": "^1.41.1", | ||
"@types/node": "^20.11.6" | ||
} | ||
} |
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,77 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: '.', | ||
/* 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 ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: [['junit', { outputFile: 'report.xml' }]], | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* 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: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}); |
Oops, something went wrong.