Skip to content

Commit

Permalink
Merge pull request #12 from ff6347/test/playwright
Browse files Browse the repository at this point in the history
test(playwright): Add basic config
  • Loading branch information
ff6347 authored Nov 11, 2023
2 parents 7e6187f + d1316c1 commit c8a0405
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 71 deletions.
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-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,8 @@ dist/
# logs

# macOS-specific files
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
tests-examples/demo-todo-app.spec.ts
4 changes: 0 additions & 4 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";
import react from "@astrojs/react";

// https://astro.build/config
export default defineConfig({
integrations: [react()],
output: "server",
adapter: netlify(),
});
137 changes: 76 additions & 61 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 @@ -12,11 +12,11 @@
"build": "export PUBLIC_BASE_URL=$DEPLOY_URL && astro build",
"check": "astro check",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"test:e2e": "playwright test"
},
"dependencies": {
"@astrojs/check": "0.3.1",
"@astrojs/netlify": "3.0.4",
"@astrojs/react": "3.0.4",
"@monaco-editor/react": "4.6.0",
"@types/p5": "1.7.2",
Expand All @@ -30,8 +30,10 @@
"typescript": "5.2.2"
},
"devDependencies": {
"@playwright/test": "1.39.0",
"@technologiestiftung/semantic-release-config": "1.2.4",
"@types/lodash.debounce": "4.0.9",
"@types/node": "20.9.0",
"mkdirp": "3.0.1",
"netlify-cli": "17.1.0",
"shx": "0.3.4"
Expand Down
91 changes: 91 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { defineConfig, devices } from "@playwright/test";

const ciConfig = {
webServer: {
command: "npm run preview",
url: "http://127.0.0.1:4321",
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
stdout: "ignore",
stderr: "pipe",
},
};
/**
* 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",
/* 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:4321",

/* 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: process.env.CI
? {
command: "npm run build && npm run preview",
url: "http://localhost:4321",
reuseExistingServer: !process.env.CI,
stdout: "ignore",
stderr: "pipe",
}
: undefined,
});
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/components/sandox.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=Inter:wght@400;700&display=swap");

:root {
--font-size: 1rem;
--spacing: 2rem;
--sans-serif: "Inter", sans-serif;
--mono: "IBM Plex Mono", monospace;
--sans-serif: system-ui, sans-serif;
--mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
"DejaVu Sans Mono", monospace;
font-weight: normal;
--fadeIn: fadeIn 0.3s ease;
}

Expand Down
Loading

0 comments on commit c8a0405

Please sign in to comment.