Skip to content

Commit ecba87b

Browse files
committed
Adding script to run all tests, but keep going if a previous one fails
1 parent 238d25e commit ecba87b

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

bin/run-vitest-all.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Get all workspace names
4+
workspaces=$(yarn workspaces --json info | jq -r 'if .type == "log" then .data | fromjson | keys[] else empty end')
5+
6+
# Flag to track if any test fails
7+
all_tests_passed=true
8+
9+
for workspace in $workspaces; do
10+
echo "Running tests in $workspace..."
11+
12+
# Run the tests and if they fail, set the flag to false
13+
yarn workspace $workspace run vitest --run || { echo "$workspace failed"; all_tests_passed=false; }
14+
done
15+
16+
# Check the flag at the end and exit with code 1 if any test failed
17+
if [ "$all_tests_passed" = false ]; then
18+
echo "Some tests failed."
19+
exit 1
20+
else
21+
echo "All tests passed!"
22+
exit 0
23+
fi

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
],
66
"scripts": {
77
"build": "node bin/build_javascript.js && node bin/build_styles.js",
8-
"test": "vitest src --run",
9-
"test:vitest": "yarn workspaces run vitest --run",
8+
"test": "bin/run-vitest-all.sh",
109
"test:jest": "yarn workspaces run jest",
1110
"lint": "yarn workspaces run eslint src test",
1211
"format": "prettier src/*/assets/src/*.ts src/*/assets/test/*.js {,src/*/}*.{json,md} --write",

0 commit comments

Comments
 (0)