Skip to content

Commit

Permalink
Merge pull request #76 from launchableinc/playwright
Browse files Browse the repository at this point in the history
Add playwright example
  • Loading branch information
Konboi authored Jan 31, 2024
2 parents 99e185b + f033f8e commit cfe2cef
Show file tree
Hide file tree
Showing 9 changed files with 794 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/playwright.yaml
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()
2 changes: 1 addition & 1 deletion go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $ go test -list . ./... | \
--build ${BUILD_NAME} \
--confidence ${CONFIDENCE} \
go-test > launchable-subset.txt

Your model is currently in training
Launchable created subset 6 for build test (test session 6) in workspace launchableinc/example

Expand Down
5 changes: 5 additions & 0 deletions playwright/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
46 changes: 46 additions & 0 deletions playwright/README.md
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
```
140 changes: 140 additions & 0 deletions playwright/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions playwright/package.json
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"
}
}
77 changes: 77 additions & 0 deletions playwright/playwright.config.ts
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,
// },
});
Loading

0 comments on commit cfe2cef

Please sign in to comment.