Skip to content

Commit e071b9e

Browse files
yjaaidiMarmicode Bot
and
Marmicode Bot
authored
test: ✅ add landing snapshot (#7)
* test: ✅ add landing snapshot * test: ✅ update snapshots --------- Co-authored-by: Marmicode Bot <[email protected]>
1 parent 538afa9 commit e071b9e

13 files changed

+83
-15
lines changed

.github/workflows/test.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ jobs:
2727
fetch-depth: 0
2828
- uses: actions/setup-node@v3
2929
with:
30-
node-version: 21
30+
node-version: 22
3131
- uses: oven-sh/setup-bun@v1
3232
with:
3333
bun-version: latest
34+
- name: Install Playwright Browsers
35+
run: bunx playwright install chromium --with-deps
3436
- run: bun install --frozen-lockfile --ignore-scripts
3537
- uses: nrwl/nx-set-shas@v4
3638

3739
- run: bunx nx-cloud start-ci-run --distribute-on="3 linux-large-js-bun"
3840
- run: bunx nx-cloud record -- nx format:check
39-
- run: bunx nx affected -t build lint test
41+
- run: bunx nx affected -t build lint test e2e
4042
- name: 🔐 Set up service account
4143
if: github.ref == 'refs/heads/main'
4244
env:
@@ -47,3 +49,10 @@ jobs:
4749
- name: 🚀 Deploy
4850
if: github.ref == 'refs/heads/main'
4951
run: bunx nx affected -t deploy --no-agents
52+
53+
- uses: actions/upload-artifact@v4
54+
if: ${{ !cancelled() }}
55+
with:
56+
name: playwright-report
57+
path: dist/.playwright/apps/cookbook/playwright-report/
58+
retention-days: 30

.github/workflows/update-snapshots.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ jobs:
2121
with:
2222
bun-version: latest
2323
- name: Install Playwright Browsers
24-
run: bunx playwright install chrome --with-deps
24+
run: bunx playwright install chromium --with-deps
2525
- run: bun install --frozen-lockfile --ignore-scripts
2626
- uses: nrwl/nx-set-shas@v4
2727

28-
- run: bunx nx affected e2e -u
28+
- run: bunx nx affected --target e2e --update-snapshots
2929

3030
- run: |
3131
git config --global user.email "[email protected]"
3232
git config --global user.name "Marmicode Bot"
33+
git add apps/*/e2e/**/*.png
3334
git diff --cached --quiet || git commit -a -m "test: ✅ update snapshots"
3435
git push
3536

.nx/workflows/bun.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
launch-templates:
22
linux-large-js-bun:
33
resource-class: 'docker_linux_amd64/large'
4-
image: 'ubuntu22.04-node20.11-v7'
4+
image: 'ubuntu22.04-node20.11-v10'
55
init-steps:
66
- name: Add bun bin to PATH
77
script: echo "PATH=$HOME/.bun/bin:$PATH" >> $NX_CLOUD_ENV
88
- name: Checkout
9-
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/checkout/main.yaml'
9+
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/checkout/main.yaml'
1010
- name: Restore Node Modules Cache
11-
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/cache/main.yaml'
11+
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
1212
env:
1313
KEY: 'bun.lockb'
1414
PATHS: 'node_modules'
1515
BASE_BRANCH: 'main'
1616
- name: Restore Browser Binary Cache
17-
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/cache/main.yaml'
17+
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
1818
env:
1919
KEY: 'bun.lockb|"browsers"'
2020
PATHS: |
@@ -28,4 +28,4 @@ launch-templates:
2828
- name: Install Node Modules (with Bun)
2929
script: bun install --frozen-lockfile --ignore-scripts
3030
- name: Install Browsers (if needed)
31-
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-browsers/main.yaml'
31+
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-browsers/main.yaml'

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["ms-playwright.playwright"]
3+
}

apps/cookbook/e2e/landing.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('landing layout', async ({ page }) => {
4+
await page.goto('/');
5+
6+
await expect(page).toHaveScreenshot({
7+
fullPage: true,
8+
});
9+
});
Loading
Loading

apps/cookbook/eslint.config.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
const nx = require('@nx/eslint-plugin');
21
const baseConfig = require('../../eslint.config.js');
2+
const nx = require('@nx/eslint-plugin');
3+
const playwright = require('eslint-plugin-playwright');
4+
5+
console.log();
36

47
module.exports = [
58
...baseConfig,
69
...nx.configs['flat/react'],
10+
{
11+
ignores: ['.docusaurus'],
12+
},
713
{
814
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
915
// Override or add rules here
1016
rules: {},
1117
},
18+
{
19+
...playwright.configs['flat/recommended'],
20+
files: ['e2e/**/*.ts'],
21+
},
1222
];

apps/cookbook/playwright.config.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
import { nxE2EPreset } from '@nx/playwright/preset';
3+
import { workspaceRoot } from '@nx/devkit';
4+
5+
const baseURL = process.env['BASE_URL'] || 'http://localhost:3000';
6+
7+
/**
8+
* See https://playwright.dev/docs/test-configuration.
9+
*/
10+
export default defineConfig({
11+
...nxE2EPreset(__filename, { testDir: './e2e' }),
12+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
13+
use: {
14+
baseURL,
15+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
16+
trace: 'on-first-retry',
17+
},
18+
/* Run your local dev server before starting the tests */
19+
webServer: {
20+
command: 'nx start cookbook',
21+
url: 'http://localhost:3000',
22+
reuseExistingServer: !process.env.CI,
23+
cwd: workspaceRoot,
24+
},
25+
projects: [
26+
{
27+
name: 'chromium',
28+
use: { ...devices['Desktop Chrome'] },
29+
},
30+
],
31+
});

bun.lockb

36.4 KB
Binary file not shown.

eslint.config.js

-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,4 @@ module.exports = [
2525
],
2626
},
2727
},
28-
{
29-
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
30-
// Override or add rules here
31-
rules: {},
32-
},
3328
];

nx.json

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
"options": {
3737
"targetName": "lint"
3838
}
39+
},
40+
{
41+
"plugin": "@nx/playwright/plugin",
42+
"options": {
43+
"targetName": "e2e"
44+
}
3945
}
4046
]
4147
}

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
"@docusaurus/types": "3.6.3",
2121
"@eslint/eslintrc": "3.2.0",
2222
"@eslint/js": "9.16.0",
23+
"@nx/devkit": "19.8.9",
2324
"@nx/eslint": "19.8.9",
2425
"@nx/eslint-plugin": "19.8.9",
26+
"@nx/playwright": "19.8.9",
2527
"@nx/react": "19.8.9",
2628
"@nx/vite": "19.8.9",
2729
"@nx/web": "19.8.9",
2830
"@nx/workspace": "19.8.9",
31+
"@playwright/test": "^1.36.0",
2932
"@testing-library/jest-dom": "6.4.2",
3033
"@testing-library/react": "15.0.6",
3134
"@typescript-eslint/eslint-plugin": "8.17.0",
@@ -35,6 +38,7 @@
3538
"eslint-config-prettier": "9.1.0",
3639
"eslint-plugin-import": "2.31.0",
3740
"eslint-plugin-jsx-a11y": "6.10.2",
41+
"eslint-plugin-playwright": "2.1.0",
3842
"eslint-plugin-react": "7.37.2",
3943
"eslint-plugin-react-hooks": "5.1.0",
4044
"firebase-tools": "13.10.2",

0 commit comments

Comments
 (0)