Skip to content

Commit 98d1922

Browse files
committed
make it easier to run tests (when we get them)
1 parent e87cf9c commit 98d1922

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed

.github/workflows/validate.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ jobs:
3535
- name: ⬣ ESLint
3636
run: npm run lint
3737

38+
# TODO: get this working again
39+
# - name: ⬇️ Install Playwright
40+
# run: npm --prefix epicshop run test:setup
41+
42+
# - name: 🧪 In-browser tests
43+
# run: npm --prefix epicshop test
44+
3845
deploy:
3946
name: 🚀 Deploy
4047
runs-on: ubuntu-latest

epicshop/in-browser-tests.spec.js

Lines changed: 8 additions & 0 deletions
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-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

epicshop/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
22
"type": "module",
3+
"scripts": {
4+
"test:setup": "playwright install chromium --with-deps",
5+
"test": "playwright test"
6+
},
37
"dependencies": {
48
"@epic-web/config": "^1.11.2",
59
"@epic-web/workshop-app": "^4.28.0",
10+
"@epic-web/workshop-utils": "^4.28.0",
611
"execa": "^9.2.0"
712
}
813
}

epicshop/playwright.config.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
workers: process.env.CI ? 1 : undefined,
14+
outputDir: path.join(tmpDir, 'playwright-test-output'),
15+
reporter: [
16+
[
17+
'html',
18+
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
19+
],
20+
],
21+
use: {
22+
baseURL: `http://localhost:${PORT}/`,
23+
trace: 'retain-on-failure',
24+
},
25+
26+
projects: [
27+
{
28+
name: 'chromium',
29+
use: { ...devices['Desktop Chrome'] },
30+
},
31+
],
32+
33+
webServer: {
34+
command: 'cd .. && npm start',
35+
port: Number(PORT),
36+
reuseExistingServer: !process.env.CI,
37+
stdout: 'pipe',
38+
stderr: 'pipe',
39+
env: { PORT },
40+
},
41+
})

0 commit comments

Comments
 (0)