Skip to content

Commit

Permalink
Test base
Browse files Browse the repository at this point in the history
  • Loading branch information
deeprobin committed Jul 29, 2023
1 parent 28ff5be commit 3cd4936
Show file tree
Hide file tree
Showing 13 changed files with 394 additions and 176 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.vscode
public
node_modules
dist
.env
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ pnpm-debug.log*

# macOS-specific files
.DS_Store
/test-results/
/playwright-report/
/playwright/.cache/
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine3.18 AS build
FROM node:20 AS build
ENV NODE_ENV=production

WORKDIR /usr/src/app
Expand All @@ -10,7 +10,7 @@ RUN pnpm install --frozen-lockfile --prod
COPY . .
RUN pnpm build --production

FROM node:20-alpine3.18 AS runtime
FROM node:20 AS runtime
LABEL org.opencontainers.image.title="Lindner IT Website"
LABEL org.opencontainers.image.description="Node HTTP-Server for Lindner IT Website (using Astro: SSR + SSG)"
LABEL org.opencontainers.image.authors="Robin Lindner <[email protected]>"
Expand All @@ -22,7 +22,7 @@ LABEL org.opencontainers.image.url="https://lindnerit.io"
WORKDIR /usr/src/app
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=80

ENV PORT=3000
EXPOSE 3000
COPY --from=build /usr/src/app/ /usr/src/app/
ENTRYPOINT ["node", "dist/server/entry.mjs"]
3 changes: 2 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export default defineConfig({
},
}), critters(), rome(), compressor()],
experimental: {
assets: true
assets: true,
viewTransitions: true
},
image: {
service: sharpImageService(),
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"test": "echo \"Error: no test specified\"",
"astro": "astro"
},
"dependencies": {
"@astrojs/deno": "^4.2.0",
"@astrojs/deno": "^4.3.0",
"@astrojs/node": "^5.3.0",
"@astrojs/prefetch": "^0.2.3",
"@astrojs/rss": "^2.4.3",
Expand All @@ -31,18 +30,21 @@
"@swup/ga-plugin": "^1.1.0",
"@swup/gtm-plugin": "^1.0.2",
"@swup/head-plugin": "^1.3.0",
"astro": "^2.9.1",
"astro": "^2.9.6",
"astro-compressor": "^0.4.0",
"astro-critters": "^1.1.39",
"astro-critters": "^1.1.40",
"astro-rome": "^0.1.18",
"astro-webmanifest": "^0.6.0",
"contentful": "^10.3.6",
"lucide-solid": "^0.241.0",
"nanostores": "^0.9.3",
"sass": "^1.64.0",
"sass": "^1.64.1",
"sharp": "^0.32.4",
"solid-icons": "^1.0.11",
"solid-js": "^1.7.8",
"swup": "^3.1.1"
},
"devDependencies": {
"@playwright/test": "^1.36.2"
}
}
77 changes: 77 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests/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/',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
{
name: 'Microsoft Edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
},
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
},
],

/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run preview',
url: 'http://localhost:3000/',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},
});
Loading

0 comments on commit 3cd4936

Please sign in to comment.