-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.ps1
63 lines (48 loc) · 1.45 KB
/
test.ps1
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
param(
[switch]
$All,
[switch]
$Client,
[switch]
$Server
)
if (-not $All -and -not $Client -and -not $Server) {
throw "must choose a parameter -All | -Client | -Server to run all the tests on your local machine"
}
Write-Host ""
$filepath = ".\env.txt"
if (Test-Path -Path $filepath) {
$txt = Get-Content -Path $filepath -Raw
$env:ENV_TXT = $txt -join [System.Environment]::NewLine;
}
else {
Write-Host "[WARN]: env.txt was not found, using env.sample.txt instead." -ForegroundColor Yellow
$filepath = ".\env.sample.txt"
$txt = Get-Content -Path $filepath -Raw
$env:ENV_TXT = $txt -join [System.Environment]::NewLine;
}
if ($All) {
Write-Host "[INFO]: running tests for both client and server..." -ForegroundColor Cyan
Write-Host "[INFO]: running client tests..." -ForegroundColor Cyan
Push-Location -Path ".\client"
npm run test:ci
Pop-Location
Write-Host "[INFO]: running server tests..." -ForegroundColor Cyan
Push-Location -Path ".\server"
npm run server:ci
Pop-Location
}
else {
if ($Client) {
Write-Host "[INFO]: running client tests..." -ForegroundColor Cyan
Push-Location -Path ".\client"
npm run test:ci
Pop-Location
}
if ($Server) {
Write-Host "[INFO]: running server tests..." -ForegroundColor Cyan
Push-Location -Path ".\server"
npm run server:ci
Pop-Location
}
}