From 9ce44f07d0201fdd4d4be8052446d4dde97e7053 Mon Sep 17 00:00:00 2001 From: Coby Date: Wed, 20 Nov 2024 16:29:06 -0500 Subject: [PATCH] fail the job if tests fail --- package.json | 2 +- run-tests.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 run-tests.sh diff --git a/package.json b/package.json index 394c6f4..ed0074b 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "build": "npm run clean && npx tsc", "start": "node build/src/index.js", "dev": "cross-env NODE_NO_WARNINGS=1 npx nodemon src/index.ts", - "test": "npx tsc && for testfile in $(find build/tests -type f -name '*.test.js'); do node $testfile || exit 1; done", + "test": "./run-tests.sh", "clean": "rimraf ./build", "gen-test-mocks": "cross-env NODE_NO_WARNINGS=1 node --loader ts-node/esm tests/mocked_sql/generate_mock_data.ts", "benchmark": "cross-env NODE_NO_WARNINGS=1 node --loader ts-node/esm benchmark/setup.ts && npx artillery run benchmark/graphql.yaml --output benchmark/report.json", diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..85823c8 --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -e +shopt -s globstar # to expand '**' into nested directories./ + +npm run build + +# find all unit tests in build and run them +for f in ./build/**/*test.js; do + echo "Running $f" + node --enable-source-maps --stack-trace-limit=1000 $f; +done