Skip to content

Commit

Permalink
make it easier to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Sep 18, 2024
1 parent bf57ef6 commit d24b765
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 74 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ jobs:
- name: ⬣ ESLint
run: npm run lint

# TODO: get this working again
# - name: ⬇️ Install Playwright
# run: npm --prefix epicshop run test:setup

# - name: 🧪 In-browser tests
# run: npm --prefix epicshop test

deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions epicshop/in-browser-tests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { setupInBrowserTests } from '@epic-web/workshop-utils/playwright.server'

const __dirname = dirname(fileURLToPath(import.meta.url))
process.env.EPICSHOP_CONTEXT_CWD = resolve(__dirname, '..')

setupInBrowserTests()
41 changes: 41 additions & 0 deletions epicshop/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os from 'os'
import path from 'path'
import { defineConfig, devices } from '@playwright/test'

const PORT = process.env.PORT || '5639'
const tmpDir = path.join(
os.tmpdir(),
'epicshop-playwright',
path.basename(new URL('../', import.meta.url).pathname),
)

export default defineConfig({
workers: process.env.CI ? 1 : undefined,
outputDir: path.join(tmpDir, 'playwright-test-output'),
reporter: [
[
'html',
{ open: 'never', outputFolder: path.join(tmpDir, 'playwright-report') },
],
],
use: {
baseURL: `http://localhost:${PORT}/`,
trace: 'retain-on-failure',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],

webServer: {
command: 'cd .. && npm start',
port: Number(PORT),
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe',
env: { PORT },
},
})
64 changes: 0 additions & 64 deletions epicshop/playwright.config.ts

This file was deleted.

10 changes: 0 additions & 10 deletions epicshop/tests/in-browser-tests.spec.ts

This file was deleted.

0 comments on commit d24b765

Please sign in to comment.