cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
scripts/test
29lines · modecode
| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | function prism_is_running() { |
| 4 | curl --silent "http://localhost:4010" >/dev/null 2>&1 |
| 5 | } |
| 6 | |
| 7 | kill_server_on_port() { |
| 8 | pids=$(lsof -t -i tcp:"$1" || echo "") |
| 9 | if [ "$pids" != "" ]; then |
| 10 | kill "$pids" |
| 11 | echo "Stopped $pids." |
| 12 | fi |
| 13 | } |
| 14 | |
| 15 | if ! prism_is_running; then |
| 16 | # When we exit this script, make sure to kill the background mock server process |
| 17 | trap 'kill_server_on_port 4010' EXIT |
| 18 | |
| 19 | # Start the dev server |
| 20 | ./scripts/mock --daemon |
| 21 | |
| 22 | # Sanity check and print a nice error message |
| 23 | if ! ./bin/check-test-server; then |
| 24 | exit |
| 25 | fi |
| 26 | fi |
| 27 | |
| 28 | # Run tests |
| 29 | ./node_modules/.bin/jest |
| 30 | |