Skip to content

Commit 19efcc2

Browse files
committed
chore: add playwright test
1 parent 99402aa commit 19efcc2

File tree

9 files changed

+98
-1409
lines changed

9 files changed

+98
-1409
lines changed

.github/workflows/build.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
build:
11+
timeout-minutes: 60
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- uses: pnpm/[email protected]
17+
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: 18
21+
22+
- name: Install dependencies
23+
run: pnpm i --frozen-lockfile
24+
25+
- name: Install Playwright Browsers
26+
run: npx playwright install --with-deps
27+
28+
- name: Build
29+
run: pnpm build
30+
31+
- name: Run Playwright tests
32+
working-directory: example
33+
run: pnpm test
34+
35+
- uses: actions/upload-artifact@v3
36+
if: always()
37+
with:
38+
name: playwright-report
39+
path: example/playwright-report/
40+
retention-days: 30
41+
42+
- name: Create Release Pull Request or Publish
43+
id: changesets
44+
uses: changesets/action@v1
45+
if: github.ref == 'refs/heads/master'
46+
with:
47+
publish: pnpm run publish
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
51+

example/jest.config.mjs

Lines changed: 0 additions & 21 deletions
This file was deleted.

example/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10-
"test": "jest"
10+
"test": "playwright test"
1111
},
1212
"dependencies": {
1313
"@ddadaal/next-typed-api-routes-runtime": "workspace:*",
@@ -20,10 +20,6 @@
2020
"@next/bundle-analyzer": "^12.0.4",
2121
"@types/react": "18.0.12",
2222
"@babel/core": ">=7.0.0 <8.0.0",
23-
"jest": "29.5.0",
24-
"jest-environment-jsdom": "29.5.0",
25-
"@testing-library/react": "14.0.0",
26-
"@testing-library/jest-dom": "5.16.5",
27-
"whatwg-fetch": "3.6.2"
23+
"@playwright/test": "1.34.3"
2824
}
2925
}

example/playwright.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from '@playwright/test';
2+
3+
export default defineConfig({
4+
// Run your local dev server before starting the tests
5+
webServer: {
6+
command: 'pnpm dev',
7+
url: 'http://127.0.0.1:3000',
8+
reuseExistingServer: !process.env.CI,
9+
stdout: "pipe",
10+
},
11+
});

example/tests/apis.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { api } from "../src/apis/api";
2+
import { test, expect } from '@playwright/test';
23

3-
it("should call zodRoute", async () => {
4+
test("should call zodRoute", async ({ page }) => {
45
const resp = await api.zodRoute({ body: { info: "test" }, query: { test: "123" } });
56

67
expect(resp.hello).toBe("test 123");

example/tests/jest.setup.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/tests/testEnv.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"name": "@ddadaal/next-typed-api-routes",
33
"version": "0.2.12",
4+
"private": true,
45
"description": "Make Next.js API Routes strongly typed with routes and clients type completion and auto-generated parameter validation",
56
"scripts": {
6-
"build": "pnpm --filter !example run build"
7+
"build": "pnpm --filter !example run build",
8+
"publish": "pnpm publish"
79
},
810
"homepage": "https://github.com/ddadaal/next-typed-api-routes#readme",
911
"devDependencies": {

0 commit comments

Comments
 (0)