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

chore/config-e2e-tests #873

Merged
merged 2 commits into from
Oct 16, 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
29 changes: 29 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Tests e2e
on:
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Build catalog
shell: bash
run: |
cp $PROJECT_DIR/eventcatalog.config.js $CATALOG_DIR/eventcatalog.config.js
cp $PROJECT_DIR/eventcatalog.styles.css $CATALOG_DIR/eventcatalog.styles.css
npm run build
env:
PROJECT_DIR: ./examples/default/
CATALOG_DIR: ./
NODE_ENV: CI # Skip analytics
- name: Run tests
run: npm run test:e2e
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ eventcatalog.styles.css

.vscode/*

git-push.sh
git-push.sh

/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ __tests__/

Dockerfile
.dockerignore

# e2e
e2e/
playwright.config.ts
6 changes: 6 additions & 0 deletions e2e/home.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'Welcome to EventCatalog' })).toBeVisible();
});
69 changes: 66 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"prepublishOnly": "npm run build:bin",
"test": "vitest --config vitest.config.ts",
"test:ci": "node scripts/ci/test.js",
"test:e2e": "playwright test",
"start": "astro dev",
"build": "npm run scripts:hydrate-content && node scripts/analytics/log-build.js && astro build",
"build:cd": "node scripts/build-ci.js",
Expand Down Expand Up @@ -52,6 +53,7 @@
"@types/diff": "^5.2.2",
"@types/lodash.merge": "4.6.9",
"@types/node": "^20.14.2",
"@types/semver": "^7.5.8",
"astro": "^4.16.5",
"astro-expressive-code": "^0.36.1",
"astro-pagefind": "^1.6.0",
Expand All @@ -77,11 +79,11 @@
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5",
"unist-util-visit": "^5.0.0",
"uuid": "^10.0.0",
"@types/semver": "^7.5.8"
"uuid": "^10.0.0"
},
"devDependencies": {
"@changesets/cli": "^2.27.5",
"@playwright/test": "^1.48.1",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"prettier": "^3.3.3",
Expand Down
39 changes: 39 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
// reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:3000', // TODO: get the port defined on eventcatalog.config.js

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
webServer: {
command: 'npm run preview',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
});
2 changes: 2 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/// <reference types="vitest" />
import { getViteConfig } from 'astro/config';
import { defaultExclude } from 'vitest/config';
import tsConfigPaths from 'vite-tsconfig-paths';

export default getViteConfig({
plugins: [tsConfigPaths()],
test: {
globals: true,
exclude: [...defaultExclude, 'e2e/**'],
},
});