Skip to content

Commit 1481c8a

Browse files
authored
Merge pull request #30 from pawcoding/test/setup-vitest
Setup vitest
2 parents c50ae79 + f47f172 commit 1481c8a

40 files changed

+4434
-786
lines changed

.github/workflows/release.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ jobs:
3333

3434
# Install dependencies
3535
- name: 📦 Install dependencies
36-
run: |
37-
npm ci
36+
run: npm ci
3837

3938
# Lint code
4039
- name: 🧹 Lint code
@@ -44,6 +43,30 @@ jobs:
4443
- name: 🧹 Check format
4544
run: npm run format:check
4645

46+
# Run tests
47+
- name: 🧪 Run unit tests
48+
run: npm run test:unit
49+
50+
# Setup PocketBase
51+
- name: 🗄️ Download and setup PocketBase
52+
run: npm run test:e2e:setup
53+
54+
# Start PocketBase
55+
- name: 🚀 Start PocketBase
56+
run: ./.pocketbase/pocketbase serve &
57+
58+
# Wait for PocketBase to be ready
59+
- name: ⏳ Wait for PocketBase
60+
run: |
61+
until curl -s --fail http://localhost:8090/api/health; do
62+
echo 'Waiting for PocketBase...'
63+
sleep 5
64+
done
65+
66+
# Run tests
67+
- name: 🧪 Run e2e tests
68+
run: npm run test:e2e
69+
4770
# Create release
4871
- name: 🚀 Create release
4972
id: release

.github/workflows/test.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: 🧪 Test code
2+
# Run this on every push except master and next
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
- "!master"
8+
- "!next"
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
# Use the latest version of Ubuntu
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
issues: write
19+
pull-requests: write
20+
id-token: write
21+
steps:
22+
# Checkout repository
23+
- name: 📥 Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
28+
# Setup Node
29+
- name: 📦 Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: "lts/*"
33+
cache: "npm"
34+
35+
# Install dependencies
36+
- name: 📦 Install dependencies
37+
run: npm ci
38+
39+
# Lint code
40+
- name: 🧹 Lint code
41+
run: npm run lint
42+
43+
# Check format
44+
- name: 🧹 Check format
45+
run: npm run format:check
46+
47+
# Run tests
48+
- name: 🧪 Run unit tests
49+
run: npm run test:unit
50+
51+
# Setup PocketBase
52+
- name: 🗄️ Download and setup PocketBase
53+
run: npm run test:e2e:setup
54+
55+
# Start PocketBase
56+
- name: 🚀 Start PocketBase
57+
run: ./.pocketbase/pocketbase serve &
58+
59+
# Wait for PocketBase to be ready
60+
- name: ⏳ Wait for PocketBase
61+
run: |
62+
until curl -s --fail http://localhost:8090/api/health; do
63+
echo 'Waiting for PocketBase...'
64+
sleep 5
65+
done
66+
67+
# Run tests
68+
- name: 🧪 Run e2e tests
69+
run: npm run test:e2e

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# build output
22
dist/
33
.eslintcache
4+
coverage/
45
# generated types
56
.astro/
67

@@ -13,7 +14,6 @@ yarn-debug.log*
1314
yarn-error.log*
1415
pnpm-debug.log*
1516

16-
1717
# environment variables
1818
.env
1919
.env.production
@@ -23,3 +23,6 @@ pnpm-debug.log*
2323

2424
# jetbrains setting folder
2525
.idea/
26+
27+
# PocketBase folder
28+
.pocketbase/

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm run lint
1+
npx lint-staged

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ pnpm-debug.log*
2424

2525
# jetbrains setting folder
2626
.idea/
27+
28+
# misc
29+
.husky/
30+
.prettierignore

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"trailingComma": "none"
2+
"trailingComma": "none",
3+
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-packagejson"]
34
}

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tseslint from "typescript-eslint";
66

77
const config = tseslint.config({
88
files: ["**/*.{js,mjs,cjs,ts}"],
9+
ignores: [".pocketbase/**/*"],
910
languageOptions: {
1011
globals: { ...globals.browser, ...globals.node }
1112
},

lint-staged.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @type {import('lint-staged').Configuration}
3+
*/
4+
export default {
5+
"!(*.ts)": "prettier --write",
6+
"*.ts": ["eslint --fix", "prettier --write"]
7+
};

0 commit comments

Comments
 (0)