From 14dd1d33583a9fb4110f7093805d58fd7bf073b1 Mon Sep 17 00:00:00 2001 From: Lucas Fernandez Date: Sat, 9 Sep 2023 19:35:16 +0200 Subject: [PATCH] Add e2e testing --- .github/workflows/ci.yml | 17 +++++- package.json | 85 +++++++++++++-------------- ui/playwright.config.ts | 2 +- ui/src/__tests__/e2e/UserFlow.spec.ts | 1 + 4 files changed, 57 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 090971a..3e046fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,18 @@ jobs: with: node-version: '18.x' cache: 'npm' - - run: npm install - - run: npm run lint - - run: npm run test + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Lint + run: npm run lint + - name: Run Tests + run: npm run test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/package.json b/package.json index 99756d6..356d64b 100644 --- a/package.json +++ b/package.json @@ -1,46 +1,43 @@ { - "name": "portfolio-app", - "version": "0.0.1", - "description": "Personal portfolio app.", - "author": "Lucas Fernandez", - "license": "ISC", - "private": true, - "repository": { - "type": "git", - "url": "git+https://github.com/lucferbux/Taller-Containerization" - }, - "homepage": "https://github.com/lucferbux/Taller-Containerization#readme", - "bugs": { - "url": "https://github.com/lucferbux/Taller-Containerization/issues" - }, - "engines": { - "node": ">=12.0.0" - }, - "scripts": { - "build": "run-p -l build:*", - "build:api": "cd ./api && npm run build", - "build:ui": "cd ./ui && npm run build", - "dev": "run-p -l dev:*", - "dev:api": "cd ./api && npm run start:dev", - "dev:ui": "cd ./ui && npm run start:dev", - "format": "prettier --write \"api/**/*.ts\" \"ui/**/*.ts\" \"ui/**/*.tsx\"", - "make": "make", - "postinstall": "run-p postinstall:*", - "postinstall:api": "cd ./api && npm install", - "postinstall:ui": "cd ./ui && npm install", - "start": "run-p start:*", - "start:api": "cd ./api && npm start", - "start:ui": "cd ./ui && npm start", - "test": "run-s test:api test:ui", - "test:api": "cd ./api && npm run test", - "test:ui": "cd ./ui && npm run test", - "lint": "run-s lint:api lint:ui", - "lint:api": "cd ./api && npm run lint", - "lint:ui": "cd ./ui && npm run lint" - }, - "dependencies": { - "npm-run-all": "^4.1.5", - "prettier": "^2.2.1" - } + "name": "portfolio-app", + "version": "0.0.1", + "description": "Personal portfolio app.", + "author": "Lucas Fernandez", + "license": "ISC", + "private": true, + "repository": { + "type": "git", + "url": "git+https://github.com/lucferbux/Taller-Containerization" + }, + "homepage": "https://github.com/lucferbux/Taller-Containerization#readme", + "bugs": { + "url": "https://github.com/lucferbux/Taller-Containerization/issues" + }, + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "run-p -l build:*", + "build:api": "cd ./api && npm run build", + "build:ui": "cd ./ui && npm run build", + "dev": "run-p -l dev:*", + "dev:api": "cd ./api && npm run dev", + "dev:ui": "cd ./ui && npm run dev", + "format": "prettier --write \"api/**/*.ts\" \"ui/**/*.ts\" \"ui/**/*.tsx\"", + "make": "make", + "start": "run-p start:*", + "start:api": "cd ./api && npm start", + "start:ui": "echo \"...available at ./ui/public\"", + "test": "run-s test:api test:ui test:e2e", + "test:api": "cd ./api && npm run test", + "test:ui": "cd ./ui && npm run test", + "test:e2e": "cd ./ui && npm run test:e2e", + "lint": "run-s lint:api lint:ui", + "lint:api": "cd ./api && npm run lint", + "lint:ui": "cd ./ui && npm run lint" + }, + "dependencies": { + "npm-run-all": "^4.1.5", + "prettier": "^2.2.1" } - \ No newline at end of file +} \ No newline at end of file diff --git a/ui/playwright.config.ts b/ui/playwright.config.ts index abf03db..96f3dc1 100644 --- a/ui/playwright.config.ts +++ b/ui/playwright.config.ts @@ -4,7 +4,7 @@ export default defineConfig({ timeout: 5000, testDir: 'src/__tests__', - reporter: 'html', + reporter: 'list', /* Configure projects for major browsers */ projects: [ { diff --git a/ui/src/__tests__/e2e/UserFlow.spec.ts b/ui/src/__tests__/e2e/UserFlow.spec.ts index 9c0d5dd..3eb0e17 100644 --- a/ui/src/__tests__/e2e/UserFlow.spec.ts +++ b/ui/src/__tests__/e2e/UserFlow.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from '@playwright/test'; // Test Landing Page and Nav Bar test('Landing page', async ({ page }) => { + await page.goto('/'); // Check that the page title is correct await expect(page).toHaveTitle('Portfolio'); // Check that the page header is correct