Skip to content

Commit 16223f6

Browse files
committed
add tests to ci
1 parent 1178164 commit 16223f6

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

.github/workflows/validate.yml

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ jobs:
3535
- name: ⬣ ESLint
3636
run: npm run lint
3737

38+
- name: 🧪 Install Playwright
39+
run: npm --prefix epicshop run test:setup
40+
41+
- name: 🧪 In-browser tests
42+
run: npm --prefix epicshop test
43+
3844
deploy:
3945
name: 🚀 Deploy
4046
runs-on: ubuntu-latest

epicshop/in-browser-tests.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { dirname, resolve } from 'path'
2+
import { fileURLToPath } from 'url'
3+
import { setupInBrowserTests } from '@epic-web/workshop-utils/playwright.server'
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url))
6+
process.env.EPICSHOP_CONTEXT_CWD = resolve(__dirname, '..')
7+
8+
setupInBrowserTests()

epicshop/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"type": "module",
3+
"scripts": {
4+
"test:setup": "playwright install chromium --with-deps",
5+
"test": "playwright test"
6+
},
37
"dependencies": {
48
"@epic-web/workshop-app": "^4.28.0",
59
"execa": "^9.1.0"

epicshop/playwright.config.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os from 'os'
2+
import path from 'path'
3+
import { defineConfig, devices } from '@playwright/test'
4+
5+
const PORT = process.env.PORT || '5639'
6+
const tmpDir = path.join(
7+
os.tmpdir(),
8+
'epicshop-playwright',
9+
path.basename(new URL('../', import.meta.url).pathname),
10+
)
11+
12+
export default defineConfig({
13+
outputDir: path.join(tmpDir, 'playwright-test-output'),
14+
reporter: [
15+
[
16+
'html',
17+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
18+
],
19+
],
20+
use: {
21+
baseURL: `http://localhost:${PORT}/`,
22+
trace: 'retain-on-failure',
23+
},
24+
25+
projects: [
26+
{
27+
name: 'chromium',
28+
use: { ...devices['Desktop Chrome'] },
29+
},
30+
],
31+
32+
webServer: {
33+
command: 'cd .. && npm start',
34+
port: Number(PORT),
35+
reuseExistingServer: !process.env.CI,
36+
stdout: 'pipe',
37+
stderr: 'pipe',
38+
env: { PORT },
39+
},
40+
})

0 commit comments

Comments
 (0)