Skip to content

Commit 5c69e58

Browse files
committed
adding est harnesses back in
1 parent 733bcfc commit 5c69e58

File tree

7 files changed

+213
-1
lines changed

7 files changed

+213
-1
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
# This is a basic workflow to help you get started with Actions
3+
4+
name: Playwright tests
5+
6+
# Controls when the workflow will run
7+
on:
8+
# Triggers the workflow on push or pull request events but only for the "main" branch
9+
push:
10+
branches: [ "main" ]
11+
pull_request:
12+
branches: [ "main" ]
13+
schedule:
14+
# nightly
15+
- cron: '0 0 * * *'
16+
17+
# Allows you to run this workflow manually from the Actions tab
18+
workflow_dispatch:
19+
20+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
21+
jobs:
22+
test:
23+
# Runs on an ubuntu runner
24+
runs-on: ubuntu-latest
25+
26+
strategy:
27+
matrix:
28+
node-version: [14.x, 16.x, 18.x]
29+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
30+
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: actions/setup-node@v3
34+
- name: Install dependencies
35+
run: npm ci
36+
- name: Install Playwright
37+
run: npx playwright install --with-deps
38+
- name: Build production build
39+
run: npm run build
40+
- name: Run your tests
41+
run: npm run playwright_test
42+
- name: Get current date
43+
id: date
44+
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
45+
- name: Upload HTML report as Artifact
46+
uses: actions/upload-artifact@v2
47+
env:
48+
TAG_NAME: test-report-${{ steps.date.outputs.date }}
49+
if: always()
50+
with:
51+
name: onDemand
52+
path: pw-report/
53+
54+
storeReports:
55+
name: Store reports
56+
if: ${{ always() }}
57+
needs: test
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Download all workflow run artifacts
61+
uses: actions/download-artifact@v3
62+
id: download
63+
- name: Publish to external repo
64+
if: always()
65+
uses: peaceiris/[email protected]
66+
with:
67+
external_repository: mspnp/intern-js-pipeline
68+
publish_branch: gh-pages
69+
personal_token: ${{ secrets.PAT_TOKEN }}
70+
publish_dir: ${{steps.download.outputs.download-path}}
71+
destination_dir: test-reports/${{ github.repository }}
72+
keep_files: true
73+
user_name: "github-actions[bot]"
74+
user_email: "github-actions[bot]@users.noreply.github.com"
75+
76+
notify-dashboard:
77+
name: Notify Dashboard
78+
if: ${{ always() }}
79+
needs: [test, storeReports]
80+
# The type of runner that the job will run on
81+
runs-on: ubuntu-latest
82+
83+
# Steps represent a sequence of tasks that will be executed as part of the job
84+
steps:
85+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
86+
- uses: actions/checkout@v3
87+
88+
# Runs a single command using the runners shell
89+
- name: Notify docusaurus repo
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
92+
run: |
93+
gh api repos/mspnp/intern-js-pipeline/dispatches \
94+
--raw-field event_type=rebuild-site
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Scheduled Playwright tests
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow nightly
6+
schedule:
7+
# nightly
8+
- cron: '0 0 * * *'
9+
10+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
11+
jobs:
12+
test:
13+
# Runs on an ubuntu runner
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [14.x, 16.x, 18.x]
19+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: actions/setup-node@v3
24+
- name: Install dependencies
25+
run: npm ci
26+
- name: Install Playwright
27+
run: npx playwright install --with-deps
28+
- name: Build production build
29+
run: npm run build
30+
- name: Run your tests
31+
run: npm run playwright_test
32+
- name: Get current date
33+
id: date
34+
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
35+
- name: Upload HTML report as Artifact
36+
uses: actions/upload-artifact@v2
37+
env:
38+
TAG_NAME: test-report-${{ steps.date.outputs.date }}
39+
if: always()
40+
with:
41+
name: ${{ steps.date.outputs.date }}
42+
path: pw-report/
43+
44+
storeReports:
45+
name: Store reports
46+
if: ${{ always() }}
47+
needs: test
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Download all workflow run artifacts
51+
uses: actions/download-artifact@v3
52+
id: download
53+
- name: Publish to external repo
54+
if: always()
55+
uses: peaceiris/[email protected]
56+
with:
57+
external_repository: mspnp/intern-js-pipeline
58+
publish_branch: gh-pages
59+
personal_token: ${{ secrets.PAT_TOKEN }}
60+
publish_dir: ${{steps.download.outputs.download-path}}
61+
destination_dir: test-reports/${{ github.repository }}
62+
keep_files: true
63+
user_name: "github-actions[bot]"
64+
user_email: "github-actions[bot]@users.noreply.github.com"
65+
66+
notify-dashboard:
67+
name: Notify Dashboard
68+
if: ${{ always() }}
69+
needs: [test, storeReports]
70+
# The type of runner that the job will run on
71+
runs-on: ubuntu-latest
72+
73+
# Steps represent a sequence of tasks that will be executed as part of the job
74+
steps:
75+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
76+
- uses: actions/checkout@v3
77+
78+
# Runs a single command using the runners shell
79+
- name: Notify dashboard repo
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
82+
run: |
83+
gh api repos/mspnp/intern-js-pipeline/dispatches \
84+
--raw-field event_type=rebuild-site

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@
2020

2121
npm-debug.log*
2222
yarn-debug.log*
23-
yarn-error.log*
23+
yarn-error.log*
24+
/test-results/
25+
/playwright-report/
26+
/playwright/.cache/

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"start": "react-scripts start",
1515
"build": "react-scripts build",
1616
"test": "react-scripts test",
17+
"playwright_test": "playwright test",
1718
"eject": "react-scripts eject"
1819
},
1920
"eslintConfig": {
@@ -30,5 +31,8 @@
3031
"last 1 firefox version",
3132
"last 1 safari version"
3233
]
34+
},
35+
"devDependencies": {
36+
"@playwright/test": "^1.22.2"
3337
}
3438
}

playwright.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { PlaywrightTestConfig } from '@playwright/test';
2+
const config: PlaywrightTestConfig = {
3+
use: {
4+
trace: 'on',
5+
baseURL: "http://localhost:3000/"
6+
},
7+
webServer: {
8+
command: 'npm run start',
9+
port: 3000,
10+
timeout: 120 * 1000,
11+
reuseExistingServer: !process.env.CI,
12+
},
13+
reporter: [
14+
['html', { outputFolder: 'pw-report' }],
15+
['json', { outputFolder: 'pw-report', outputFile: 'report.json' }]
16+
],
17+
};
18+
export default config;

tests/Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Testing
2+
To run react tests run `npm run test`.
3+
To run playwright tests run `npm run playwright_test`.

tests/playwright.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('basic test', async ({ page }) => {
4+
await page.goto('/');
5+
await expect(page.locator('div div')).toContainText('Hello World');
6+
})

0 commit comments

Comments
 (0)