From ccf1fb8fcb30de8d450b1637996eff912f9eb72d Mon Sep 17 00:00:00 2001 From: Andrew Rumble Date: Thu, 13 Nov 2025 10:36:08 +0000 Subject: [PATCH] Merge pull request #29662 from overleaf/ar-allow-esm-tests-to-be-grepped [web] Split vitest tests and spread args GitOrigin-RevId: d0e06836fc4f4b9de50def456aef7f0ecb6cb128 --- services/web/bin/test_unit_run_dir | 32 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/services/web/bin/test_unit_run_dir b/services/web/bin/test_unit_run_dir index 4d5d5ecb9a..320b075ce5 100755 --- a/services/web/bin/test_unit_run_dir +++ b/services/web/bin/test_unit_run_dir @@ -3,15 +3,15 @@ declare -a vitest_args=("$@") has_mocha_test=0 -has_vitest_test=0 +has_sequential_test=0 for dir_path in "$@"; do if [ -n "$(find "$dir_path" -name "*.js" -type f -print -quit 2>/dev/null)" ]; then has_mocha_test=1 fi - if [ -n "$(find "$dir_path" -name "*.test.mjs" -type f -print -quit 2>/dev/null)" ]; then - has_vitest_test=1 + if [ -n "$(find "$dir_path" -name "*.sequential.test.mjs" -type f -print -quit 2>/dev/null)" ]; then + has_sequential_test=1 fi done @@ -26,24 +26,26 @@ fi echo "Running unit tests in directory: $*" -# Remove this if/else when we have converted all module tests to vitest. -if (( has_vitest_test == 1 )); then - npm run test:unit:esm -- "${vitest_args[@]}" - vitest_status=$? + +npm run test:unit:esm:parallel -- "${vitest_args[@]}" +vitest_parallel_status=$? +if (( has_sequential_test == 0 )); then + echo "No sequential vitest tests found, skipping sequential vitest step." + vitest_sequential_status=0 else - echo "No vitest tests found in $*, skipping vitest step." - vitest_status=0 + npm run test:unit:esm:sequential -- "${vitest_args[@]}" + vitest_sequential_status=$? fi if (( has_mocha_test == 1 )); then mocha --recursive --timeout 25000 --exit --grep="$MOCHA_GREP" --require test/unit/bootstrap.js --extension=js "$@" mocha_status=$? else - echo "No mocha tests found in $TARGET_DIR, skipping mocha step." + echo "No mocha tests found, skipping mocha step." mocha_status=0 fi -if [ "$mocha_status" -eq 0 ] && [ "$vitest_status" -eq 0 ]; then +if [ "$mocha_status" -eq 0 ] && [ "$vitest_sequential_status" -eq 0 ] && [ "$vitest_parallel_status" -eq 0 ]; then exit 0 fi @@ -53,8 +55,12 @@ if [ "$mocha_status" -ne 0 ]; then echo "Mocha tests failed with status: $mocha_status" fi -if [ "$vitest_status" -ne 0 ]; then - echo "Vitest tests failed with status: $vitest_status" +if [ "$vitest_parallel_status" -ne 0 ]; then + echo "Vitest parallel tests failed with status: $vitest_parallel_status" +fi + +if [ "$vitest_sequential_status" -ne 0 ]; then + echo "Vitest sequential tests failed with status: $vitest_sequential_status" fi exit 1