fix(frontend): Controller tests slagen
This commit is contained in:
		
							parent
							
								
									b90c326b5a
								
							
						
					
					
						commit
						e4945fac66
					
				
					 2 changed files with 16 additions and 11 deletions
				
			
		|  | @ -7,7 +7,7 @@ | |||
|     "main": "dist/app.js", | ||||
|     "scripts": { | ||||
|         "build": "cross-env NODE_ENV=production tsc --build", | ||||
|         "predev": "cross-env cd .. && npm run build && cd backend", | ||||
|         "predev": "tsc --build ../common/tsconfig.json", | ||||
|         "dev": "cross-env NODE_ENV=development tsx tool/seed.ts && tsx watch --env-file=.env.development.local src/app.ts", | ||||
|         "start": "cross-env NODE_ENV=production node --env-file=.env dist/app.js", | ||||
|         "format": "prettier --write src/", | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| import { spawn } from "child_process"; | ||||
| import { ChildProcess } from "node:child_process"; | ||||
| import { ChildProcess, execSync } from 'node:child_process'; | ||||
| 
 | ||||
| let wasRunningBefore: boolean; | ||||
| let backendProcess: ChildProcess; | ||||
| 
 | ||||
| async function waitForEndpoint(url: string, delay = 1000, retries = 60): Promise<void> { | ||||
|  | @ -15,12 +16,14 @@ async function waitForEndpoint(url: string, delay = 1000, retries = 60): Promise | |||
| } | ||||
| 
 | ||||
| export async function setup(): Promise<void> { | ||||
|     // Spin up the database
 | ||||
|     spawn("docker", ["compose", "up", "db", "--detach"], { | ||||
|         cwd: "..", | ||||
|         stdio: "inherit", | ||||
|     }); | ||||
|     // Check if the database container is already running
 | ||||
|     const containerCheck = execSync("docker ps --filter 'name=db' --format '{{.Names}}'"); | ||||
|     wasRunningBefore = !(containerCheck.toString().includes("db")); | ||||
| 
 | ||||
|     // Spin up the database
 | ||||
|     execSync("docker compose up db --detach"); | ||||
| 
 | ||||
|     // Spin up the backend
 | ||||
|     backendProcess = spawn("npm", ["run", "dev"], { | ||||
|         cwd: "../backend", | ||||
|         stdio: "inherit", | ||||
|  | @ -35,8 +38,10 @@ export async function teardown(): Promise<void> { | |||
|         backendProcess.kill(); | ||||
|     } | ||||
| 
 | ||||
|     if (wasRunningBefore) { | ||||
|         spawn("docker", ["compose", "down"], { | ||||
|             cwd: "..", | ||||
|             stdio: "inherit", | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Reference in a new issue