diff --git a/bin/run.sh b/bin/run.sh new file mode 100755 index 0000000..aca4806 --- /dev/null +++ b/bin/run.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e +# Launch Playwright using Docker +docker run -d --rm \ + --name "e2e-fullstack-challenge" \ + -v "$PWD":/app \ + -w /app \ + -p 3000:3000 \ + -p 3001:3001 \ + mcr.microsoft.com/playwright:v1.52.0-noble + +npm run dev & +echo "Starting services..." +npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui diff --git a/package.json b/package.json index e9afc7f..ffbcfbf 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "concurrently \"npm run dev:backend\" \"npm run dev:frontend\"", "dev:backend": "tsx watch src/backend/server.ts", - "dev:frontend": "http-server src/frontend -p 3001 -c-1", + "dev:frontend": "vite src/frontend --port 3001 --open", "build": "npm run build:backend && npm run build:frontend", "build:backend": "tsc", "build:frontend": "tsc -p tsconfig.frontend.json", @@ -27,6 +27,8 @@ "concurrently": "^8.2.2", "http-server": "^14.1.1", "tsx": "^4.7.0", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "vite": "^5.4.19", + "wait-on": "^8.0.4" } -} \ No newline at end of file +} diff --git a/playwright.Dockerfile b/playwright.Dockerfile new file mode 100644 index 0000000..3fd1626 --- /dev/null +++ b/playwright.Dockerfile @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/playwright:v1.52.0-noble + +WORKDIR /app + +COPY package.json package-lock.json ./ + +RUN npm i --frozen-lockfile; + +COPY tests ./ +COPY playwright.config.ts . + +CMD ["npx", "playwright", "test"] diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..1379c35 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'vite'; + +export default defineConfig({ + root: 'src/frontend', + server: { + port: 3001, + } +});