@@ -18,18 +18,30 @@ export MDB_ACCURACY_RUN_ID=$(npx uuid v4)
1818# npm run test:accuracy -- tests/accuracy/some-test.test.ts
1919TEST_PATH_PATTERN=" ${1:- tests/ accuracy} "
2020shift || true
21- node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPattern " $TEST_PATH_PATTERN " " $@ "
21+ node --experimental-vm-modules node_modules/jest/bin/jest.js --bail -- testPathPattern " $TEST_PATH_PATTERN " " $@ "
2222
23- # Each test run submits an accuracy snapshot entry for each prompt with the
24- # accuracyRunStatus: "in-progress". When all the tests are done and jest exits
25- # with an exit code of 0, we can safely mark accuracy run as finished otherwise
26- # failed.
23+ # Preserving the exit code from test run to correctly notify in the CI
24+ # environments when the tests fail.
2725JEST_EXIT_CODE=$?
26+
27+ # Each test run submits an accuracy snapshot entry with the accuracyRunStatus:
28+ # "in-progress". When all the tests are done and jest exits with an exit code of
29+ # 0, we can safely mark accuracy run as finished otherwise failed.
30+
31+ # This "outside-the-tests-status-update" is arising out of the fact that each
32+ # test suite stores their own accuracy run data in the storage and this setup
33+ # might lead to data inconsistency when the tests fail. To overcome that each
34+ # accuracy snapshot entry has a status which by default is "in-progress" and is
35+ # updated when the tests either pass (all our accuracy tests are supposed to
36+ # pass unless some errors occurs during the test runs), or fail.
37+
38+ # This is necessary when comparing one accuracy run with another as we wouldn't
39+ # want to compare against an incomplete run.
2840if [ $JEST_EXIT_CODE -eq 0 ]; then
2941 MDB_ACCURACY_RUN_STATUS=" done" npx tsx scripts/update-accuracy-run-status.ts || echo " Warning: Failed to update accuracy run status to 'done'"
3042else
3143 MDB_ACCURACY_RUN_STATUS=" failed" npx tsx scripts/update-accuracy-run-status.ts || echo " Warning: Failed to update accuracy run status to 'failed'"
3244fi
3345
34- # Preserve the original Jest exit code for CI
46+
3547exit $JEST_EXIT_CODE
0 commit comments