Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: init e2e workflow setup #1086

Merged
merged 17 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: E2E Tests

on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
e2e:
runs-on: ubuntu-latest

env:
DATABASE_URL: "postgresql://postgres:secret@localhost:5432/postgres"
NEXTAUTH_URL: http://localhost:3000/api/auth
GITHUB_ID: ${{ secrets.E2E_GITHUB_ID }}
GITHUB_SECRET: ${{ secrets.E2E_GITHUB_SECRET }}
NEXTAUTH_SECRET: "please_keep_this_secret"

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'

- name: Run docker-compose
uses: hoverkraft-tech/[email protected]
with:
compose-file: "./docker-compose.yml"
services: |
db

- name: Wait for DB to be ready
run: |
until nc -z localhost 5432; do
echo "Waiting for database connection..."
sleep 5
done

- name: Install dependencies
run: npm install

- name: Install Playwright browsers
run: npx playwright install --with-deps

- name: Seed database
run: |
npm run db:push
npm run db:seed

- name: Run Playwright tests
run: npx playwright test --reporter=html

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
2 changes: 1 addition & 1 deletion e2e/articles.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "playwright/test";

test.describe("Articles", () => {
test.skip("Articles", () => {
test("Should load more articles when scrolling to the end of the page", async ({
page,
}) => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"dev:e2e": "ENV=E2E next dev",
"build": "next build",
"ci-build": "next build",
"start": "next start",
Expand Down
12 changes: 7 additions & 5 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export default defineConfig({
// },

/* Test against mobile viewports. */
{
name: "Mobile Chrome",
use: { ...devices["Pixel 5"] },
},
// {
// name: "Mobile Chrome",
// use: { ...devices["Pixel 5"] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
Expand All @@ -69,9 +69,11 @@ export default defineConfig({
// },
],

outputDir: "playwright-report",

/* Run your local dev server before starting the tests */
webServer: {
command: "npm run dev",
command: "npm run dev:e2e",
url: "http://127.0.0.1:3000",
reuseExistingServer: !process.env.CI,
},
Expand Down
Loading