Skip to content

Commit 2cb0f48

Browse files
committed
add automated way to run tests
1 parent 9490a7e commit 2cb0f48

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ workspace/
55
**/build/
66
**/public/build
77
**/playwright-report
8+
**/test-results
89
data.db
910
/playground
1011
**/tsconfig.tsbuildinfo

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: 2 additions & 1 deletion
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"type": "module",
3+
"scripts": {
4+
"test": "playwright test"
5+
},
36
"dependencies": {
47
"@epic-web/config": "^1.11.2",
5-
"@epic-web/workshop-app": "^4.27.0"
8+
"@epic-web/workshop-app": "^4.27.0",
9+
"@epic-web/workshop-utils": "^4.27.0"
610
}
711
}

epicshop/playwright.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
3+
const PORT = process.env.PORT || '5639'
4+
5+
export default defineConfig({
6+
reporter: 'html',
7+
use: {
8+
baseURL: `http://localhost:${PORT}/`,
9+
trace: 'retain-on-failure',
10+
},
11+
12+
projects: [
13+
{
14+
name: 'chromium',
15+
use: { ...devices['Desktop Chrome'] },
16+
},
17+
],
18+
19+
webServer: {
20+
command: 'cd .. && npm start',
21+
port: Number(PORT),
22+
reuseExistingServer: !process.env.CI,
23+
stdout: 'pipe',
24+
stderr: 'pipe',
25+
env: { PORT },
26+
},
27+
})

0 commit comments

Comments
 (0)