From 8616183660535a8ab1b2f51887f7017d9d16d3f4 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 8 Jun 2025 02:47:10 +0800 Subject: [PATCH] do unit test when building frontend files --- build.bat | 11 +++++++++++ build.sh | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/build.bat b/build.bat index b7aa23f4..0bfb3fad 100644 --- a/build.bat +++ b/build.bat @@ -191,6 +191,17 @@ goto :pre_parse_args ) ) + if "%NO_TEST%"=="0" ( + echo Executing frontend unit testing... + + call npm run test + + if !errorlevel! neq 0 ( + call :echo_red "Error: Failed to pass unit testing" + goto :end + ) + ) + endlocal echo Building frontend files(%RELEASE_TYPE%)... diff --git a/build.sh b/build.sh index f9cd27f1..3f5202d6 100755 --- a/build.sh +++ b/build.sh @@ -179,6 +179,17 @@ build_frontend() { fi fi + if [ "$NO_TEST" = "0" ]; then + echo "Executing frontend unit testing..." + + npm run test + + if [ "$?" != "0" ]; then + echo_red "Error: Failed to pass unit testing" + exit 1 + fi + fi + echo "Building frontend files ($RELEASE_TYPE)..." if [ "$RELEASE" = "0" ]; then