Skip to content

Commit 5fdb33c

Browse files
committed
feat: Added playwright to example site + gh action for CI
1 parent 3bc0273 commit 5fdb33c

File tree

11 files changed

+171
-5
lines changed

11 files changed

+171
-5
lines changed

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Thumbs.db
1515
########
1616
*.log
1717

18-
node_modules/*
18+
*/node_modules
1919
.markdownlint.json
2020
resources/*
2121

@@ -27,4 +27,9 @@ public/*
2727
exampleSite/public
2828

2929
# Python
30-
.venv
30+
.venv
31+
32+
# Playwright
33+
/coverage
34+
*/test-results
35+
*/playwright-report

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ list help::
1212
@echo " biome-lint: Runs the biome linter."
1313
@echo " biome-all: Runs both the lint and formatting commands."
1414
@echo " (Set BIOME_ARGS to add additional arguments to biome command (ex: make biome-all BIOME_ARGS=write))"
15+
@echo "<PRE-COMMIT>"
16+
@echo " setup-pre-commit: Sets up pre-commit (assuming it is installed)"
17+
@echo "<PLAYWRIGHT TESTS>"
18+
@echo " test: Runs playwright against the old theme."
1519

16-
.PHONY: biome-format biome-lint biome-all setup-pre-commit
17-
BIOME_ARGS ?=
20+
.PHONY: biome-format biome-lint biome-all setup-pre-commit tests
1821
FLAG :=
1922
ifeq ($(BIOME_ARGS), write)
2023
FLAG := $(WRITE_FLAG)
@@ -36,3 +39,6 @@ setup-pre-commit:
3639
pre-commit install --hook-type commit-msg; \
3740
echo "pre-commit hooks have been successfully installed."; \
3841
fi
42+
43+
tests:
44+
cd tests && npx playwright test

biome.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"**/coveo.css",
2323
"**/f5-hugo.css",
2424
"**/highlight.css",
25-
"**/*-overrides.css"
25+
"**/*-overrides.css",
26+
"public/*",
27+
"test-results/*"
2628
]
2729
},
2830
"formatter": {

tests/package-lock.json

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "nginx-docs-theme-test",
3+
"version": "1.0.0",
4+
"private": "true",
5+
"devDependencies": {
6+
"@playwright/test": "^1.48.0"
7+
}
8+
}

tests/playwright.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './src',
5+
fullyParallel: true,
6+
workers: 1,
7+
outputDir: './test-results',
8+
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',
9+
reporter: [['html', { outputFolder: './playwright-report' }]],
10+
use: {
11+
baseURL: 'http://127.0.0.1:1314',
12+
screenshots: 'only-on-failure',
13+
video: 'retain-on-failure',
14+
trace: 'on-first-retry',
15+
},
16+
projects: [
17+
{
18+
name: 'chromium',
19+
use: { ...devices['Desktop Chrome'] },
20+
},
21+
{
22+
name: 'firefox',
23+
use: { ...devices['Desktop Firefox'] },
24+
},
25+
{
26+
name: 'webkit',
27+
use: { ...devices['Desktop Safari'] },
28+
},
29+
{
30+
name: 'Mobile Chrome',
31+
use: { ...devices['Pixel 5'] },
32+
},
33+
],
34+
webServer: {
35+
command:
36+
'cd ../exampleSite && hugo mod get && hugo --gc -e production && hugo serve --port 1314',
37+
url: 'http://127.0.0.1:1314',
38+
stdout: 'ignore',
39+
},
40+
expect: {
41+
toHaveScreenshot: {
42+
pathTemplate:
43+
'{testDir}/__screenshots__{/projectName}/{testFilePath}/{arg}{ext}',
44+
},
45+
},
46+
});
64.1 KB
Loading
198 KB
Loading
201 KB
Loading
198 KB
Loading

0 commit comments

Comments
 (0)