Skip to content

A local-first personal finance app

[AI] Fix flaky API test timeouts and use sync file write in tests (#7806)

Matiss Janis Aboltins50feba1afb28
diff --git a/packages/api/vite.config.mts b/packages/api/vite.config.mts
index 5614095c6f..595d8acb8f 100644
--- a/packages/api/vite.config.mts
+++ b/packages/api/vite.config.mts
@@ -85,6 +85,12 @@ export default defineConfig({
},
test: {
globals: true,
+ // Each test loads a budget file and runs all DB migrations, which can be
+ // slow on busy CI runners; the default 5s timeout is too tight and causes
+ // flaky timeouts (and a cascade of unhandled rejections from in-flight work
+ // continuing after teardown).
+ testTimeout: 20_000,
+ hookTimeout: 20_000,
onConsoleLog(log: string, type: 'stdout' | 'stderr'): boolean | void {
// print only console.error
return type === 'stderr';
diff --git a/packages/sync-server/src/app-sync.test.ts b/packages/sync-server/src/app-sync.test.ts
index bbfa24f325..6bccc70ffb 100644
--- a/packages/sync-server/src/app-sync.test.ts
+++ b/packages/sync-server/src/app-sync.test.ts
@@ -502,9 +502,7 @@ describe('/upload-user-file', () => {
],
);
- fs.writeFile(getPathForUserFile(fileId), oldFileContent, err => {
- if (err) throw err;
- });
+ fs.writeFileSync(getPathForUserFile(fileId), oldFileContent);
const res = await request(app)
.post('/upload-user-file')
diff --git a/upcoming-release-notes/7806.md b/upcoming-release-notes/7806.md
new file mode 100644
index 0000000000..4fb2714b03
--- /dev/null
+++ b/upcoming-release-notes/7806.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Fix flaky API test timeouts and use a synchronous file write in the sync-server upload test