-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.ps1
More file actions
87 lines (73 loc) · 2.9 KB
/
run-tests.ps1
File metadata and controls
87 lines (73 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# PowerShell script for running tests
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# Activate Python venv
try {
& atests\.venv\Scripts\Activate.ps1
} catch {
Write-Error "Missing atests\.venv. Run setup script first."
exit 1
}
# Setup cleanup function
function Cleanup {
Write-Host "🛑 Cleaning up services..."
if (Test-Path $env:TEMP\backend.pid) {
$backendPid = Get-Content $env:TEMP\backend.pid
Stop-Process -Id $backendPid -Force -ErrorAction SilentlyContinue
Remove-Item $env:TEMP\backend.pid -Force
}
if (Test-Path $env:TEMP\frontend.pid) {
$frontendPid = Get-Content $env:TEMP\frontend.pid
Stop-Process -Id $frontendPid -Force -ErrorAction SilentlyContinue
Remove-Item $env:TEMP\frontend.pid -Force
}
Get-Process | Where-Object { $_.Name -match "node" -and $_.CommandLine -match "vite|ts-node-dev" } |
ForEach-Object { Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue }
}
try {
# Start backend service
Write-Host "🚀 Starting backend service..."
Push-Location backend
$backendProcess = Start-Process cmd.exe -ArgumentList "/c", "npm run dev" -NoNewWindow -PassThru
$backendProcess.Id | Out-File -FilePath $env:TEMP\backend.pid
Pop-Location
# Start frontend service
Write-Host "🚀 Starting frontend service..."
Push-Location frontend
$frontendProcess = Start-Process cmd.exe -ArgumentList "/c", "npm run dev" -NoNewWindow -PassThru
$frontendProcess.Id | Out-File -FilePath $env:TEMP\frontend.pid
Pop-Location
# Wait for both services to be ready
Write-Host "⏳ Waiting for services to start..."
$ready = $false
$attempts = 0
while (-not $ready -and $attempts -lt 30) {
$attempts++
$backendReady = $false
$frontendReady = $false
try {
$backendResponse = Invoke-WebRequest -Uri "http://localhost:3000/health" -UseBasicParsing -ErrorAction SilentlyContinue
if ($backendResponse.StatusCode -eq 200) {
$backendReady = $true
}
} catch {}
try {
$frontendResponse = Invoke-WebRequest -Uri "http://localhost:5173/health" -UseBasicParsing -ErrorAction SilentlyContinue
if ($frontendResponse.StatusCode -eq 200) {
$frontendReady = $true
}
} catch {}
if ($backendReady -and $frontendReady) {
Write-Host "🎉 Both services are ready!"
$ready = $true
break
}
Write-Host "⏳ Attempt $attempts/30: Waiting... (Backend: $backendReady, Frontend: $frontendReady)"
Start-Sleep -Seconds 1
}
# Run tests
Write-Host "🧪 Running Robot Framework tests..."
robot --outputdir atests/results atests/
} finally {
# Always clean up, even if there's an error
Cleanup
}