Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion handwritten/firestore/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ const config = {
"enable-source-maps": true,
"throw-deprecation": true,
"timeout": 10000,
"recursive": true
"recursive": true,
// Number of times to retry a failed test.
"retries": Number(process.env.TEST_RETRIES) || 0,
// Logs retried tests.
"require": [require.resolve('./scripts/mocha-retry.js')]
}
if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
delete config['throw-deprecation'];
Expand Down
2 changes: 2 additions & 0 deletions handwritten/firestore/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ steps:
env:
- 'GCLOUD_PROJECT=${_GCP_PROJECT_ID}' # Pass project ID via build variable
- 'FIRESTORE_DATABASE_ID=firestore-standard'
# Retry failing tests up to 3 times.
- 'TEST_RETRIES=3'
id: 'run-system-tests'
waitFor: ['install-dependencies']
# For Secret Manager, uncomment these (adjust secret name and volume path as needed):
Expand Down
30 changes: 30 additions & 0 deletions handwritten/firestore/scripts/mocha-retry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Mocha root hook plugin, loaded by .mocharc.js when TEST_RETRIES is set. Mocha
// reports a test that passes on a retry as a plain pass, so log the retries to
// keep flaky tests visible.

exports.mochaHooks = {
beforeEach() {
const test = this.currentTest;
// 0 on a test's first attempt, so anything higher means this is a retry.
const retry = test.currentRetry();
if (retry > 0) {
console.log(
` [retry] attempt ${retry + 1}/${test.retries() + 1}: ${test.fullTitle()}`,
);
}
},
};
Loading