File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+
13+ services :
14+ postgres :
15+ image : postgres:16
16+ env :
17+ POSTGRES_USER : postgres
18+ POSTGRES_PASSWORD : postgres
19+ POSTGRES_DB : blog_api_test
20+ ports :
21+ - 5432:5432
22+ options : >-
23+ --health-cmd="pg_isready -U postgres"
24+ --health-interval=10s
25+ --health-timeout=5s
26+ --health-retries=5
27+
28+ env :
29+ DATABASE_URL : postgres://postgres:postgres@localhost:5432/blog_api_test
30+ NODE_ENV : development
31+ ACCESS_TOKEN_SECRET : test-access-secret
32+ REFRESH_TOKEN_SECRET : test-refresh-secret
33+
34+ steps :
35+ - name : Checkout repo
36+ uses : actions/checkout@v4
37+
38+ - name : Setup Node
39+ uses : actions/setup-node@v4
40+ with :
41+ node-version : 20
42+
43+ - name : Enable pnpm
44+ run : corepack enable
45+
46+ - name : Install dependencies
47+ run : pnpm install --frozen-lockfile
48+
49+ - name : Run DB migrations
50+ run : pnpm db:migrate
51+
52+ - name : Run tests
53+ run : pnpm test
Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ export async function createUserAndLogin(
1717 password : "password123" ,
1818 } ) ;
1919
20+ if ( signupRes . status !== 201 ) {
21+ throw new Error (
22+ `Signup failed: ${ signupRes . status } ${ JSON . stringify ( signupRes . body ) } `
23+ ) ;
24+ }
25+
2026 const userId = signupRes . body . data . user . id ;
2127
2228 if ( role !== "user" ) {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import { defineConfig } from "vitest/config" ;
22import tsconfigPaths from "vite-tsconfig-paths" ;
3+ import dotenv from "dotenv" ;
4+ import path from "path" ;
5+
6+ dotenv . config ( {
7+ path : path . resolve ( process . cwd ( ) , ".env.test" ) ,
8+ } ) ;
39
410export default defineConfig ( {
511 plugins : [ tsconfigPaths ( ) ] ,
612 test : {
713 environment : "node" ,
814 globals : true ,
9- setupFiles : [
10- "./tests/setup/env-loader.ts" ,
11- "./tests/setup/global-setup.ts" ,
12- ] ,
15+ setupFiles : [ "./tests/setup/global-setup.ts" ] ,
1316 } ,
1417} ) ;
You can’t perform that action at this time.
0 commit comments