Skip to content

Commit 50ad4af

Browse files
B4nanclaude
andauthored
chore: update CI to Node 22 and fix lockfile (#80)
* chore: update CI to Node 22 and fix lockfile Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: migrate from jest to vitest with swc, add Node 24 to CI - Replace jest/ts-jest/@types/jest with vitest/unplugin-swc/@swc-node/register/@swc/core - Drop ts-node in favor of SWC - Add Node 24 to CI matrix - Use tmpfs for MongoDB data and healthcheck with --wait in CI - Remove jest.config.ts, add vitest.config.ts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: move PublisherType enum before class to fix SWC TDZ error SWC enforces temporal dead zone strictly, so the enum must be declared before the class that references it in decorators. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b4bf33b commit 50ad4af

File tree

9 files changed

+1346
-3668
lines changed

9 files changed

+1346
-3668
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
node-version: [ 18, 20, 22 ]
17+
node-version: [ 22, 24 ]
1818
steps:
1919
- name: Checkout Source code
2020
uses: actions/checkout@v6
@@ -30,7 +30,7 @@ jobs:
3030
corepack prepare yarn@stable --activate
3131
3232
- name: Init docker
33-
run: docker compose up -d
33+
run: docker compose up -d --wait
3434

3535
- name: Install
3636
run: yarn

app/controllers/author.controller.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import request from 'supertest';
2-
import expect from 'expect';
32
import { app, DI, init } from '../server';
43

54
describe('author controller', () => {

app/controllers/book.controller.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import request from 'supertest';
2-
import expect from 'expect';
32
import { init, app, DI } from '../server';
43

54
describe('book controller', () => {

app/entities/Publisher.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { Entity, Enum, OneToMany, PrimaryKey, Property, SerializedPrimaryKey } f
22
import { ObjectId, Collection } from '@mikro-orm/mongodb';
33
import { Book } from './Book';
44

5+
export enum PublisherType {
6+
LOCAL = 'local',
7+
GLOBAL = 'global',
8+
}
9+
510
@Entity()
611
export class Publisher {
712

@@ -26,8 +31,3 @@ export class Publisher {
2631
}
2732

2833
}
29-
30-
export enum PublisherType {
31-
LOCAL = 'local',
32-
GLOBAL = 'global',
33-
}

docker-compose.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
version: "3.4"
2-
31
services:
42
mongo:
53
container_name: mongo
64
image: mongo:8.2
75
ports:
86
- "27017:27017"
9-
volumes:
10-
- mongo:/data/db
11-
12-
volumes:
13-
mongo:
7+
tmpfs:
8+
- /data/db
9+
healthcheck:
10+
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
11+
interval: 5s
12+
timeout: 5s
13+
retries: 10

jest.config.ts

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

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,31 @@
1111
"start": "tsc && node dist/server",
1212
"start:dev": "tsc-watch --onSuccess \"node dist/server\"",
1313
"start:prod": "tsc && node dist/server",
14-
"test": "jest --runInBand --silent"
14+
"test": "vitest run",
15+
"test:watch": "vitest"
1516
},
1617
"dependencies": {
1718
"@mikro-orm/core": "^7.0.1",
1819
"@mikro-orm/decorators": "^7.0.1",
1920
"@mikro-orm/mongodb": "^7.0.1",
20-
"reflect-metadata": "^0.2.0",
2121
"express": "^4.18.2",
2222
"express-promise-router": "^4.1.1",
23+
"reflect-metadata": "^0.2.0",
2324
"tsc-watch": "^7.0.0",
2425
"typescript": "5.9.3"
2526
},
2627
"devDependencies": {
2728
"@mikro-orm/cli": "^7.0.1",
29+
"@swc-node/register": "^1.11.1",
30+
"@swc/core": "^1.15.3",
2831
"@types/express": "^4.17.21",
2932
"@types/express-promise-router": "^3.0.0",
30-
"@types/jest": "30.0.0",
31-
"@types/node": "24.12.0",
33+
"@types/node": "^24.0.0",
3234
"@types/supertest": "^7.0.0",
33-
"jest": "30.3.0",
3435
"supertest": "^7.0.0",
35-
"ts-jest": "^29.1.2",
36-
"ts-node": "^10.9.0",
37-
"tsx": "^4.19.0"
36+
"tsx": "^4.19.0",
37+
"unplugin-swc": "^1.5.9",
38+
"vitest": "^4.1.0"
3839
},
3940
"mikro-orm": {
4041
"configPaths": [

vitest.config.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { defineConfig } from 'vitest/config';
2+
import swc from 'unplugin-swc';
3+
4+
export default defineConfig({
5+
plugins: [
6+
swc.vite({
7+
jsc: {
8+
target: 'es2024',
9+
transform: {
10+
legacyDecorator: true,
11+
decoratorMetadata: true,
12+
},
13+
},
14+
sourceMaps: true,
15+
}),
16+
],
17+
test: {
18+
environment: 'node',
19+
include: ['app/**/*.spec.ts'],
20+
globals: true,
21+
setupFiles: ['reflect-metadata'],
22+
coverage: {
23+
reporter: ['clover', 'json', 'lcov', 'text'],
24+
include: ['app/**/*.ts'],
25+
},
26+
disableConsoleIntercept: true,
27+
clearMocks: true,
28+
fileParallelism: false,
29+
testTimeout: 60_000,
30+
},
31+
});

0 commit comments

Comments
 (0)