@@ -18,18 +18,30 @@ export MDB_ACCURACY_RUN_ID=$(npx uuid v4)
18
18
# npm run test:accuracy -- tests/accuracy/some-test.test.ts
19
19
TEST_PATH_PATTERN=" ${1:- tests/ accuracy} "
20
20
shift || 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 " " $@ "
22
22
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.
27
25
JEST_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.
28
40
if [ $JEST_EXIT_CODE -eq 0 ]; then
29
41
MDB_ACCURACY_RUN_STATUS=" done" npx tsx scripts/update-accuracy-run-status.ts || echo " Warning: Failed to update accuracy run status to 'done'"
30
42
else
31
43
MDB_ACCURACY_RUN_STATUS=" failed" npx tsx scripts/update-accuracy-run-status.ts || echo " Warning: Failed to update accuracy run status to 'failed'"
32
44
fi
33
45
34
- # Preserve the original Jest exit code for CI
46
+
35
47
exit $JEST_EXIT_CODE
0 commit comments