Skip to content

Commit e071b9e

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

File tree

13 files changed

+83
-15
lines changed

13 files changed

+83
-15
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 11 additions & 1 deletion
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

Lines changed: 31 additions & 0 deletions
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.

0 commit comments

Comments
 (0)