Skip to content

Commit fa36608

Browse files
committed
fix(ApiDataFactory): Add delay after cleanup for Docker file system propagation
In Docker environments with volume mounts, there can be a delay between: 1. DELETE HTTP request completing successfully 2. json-server writing updated db.json to disk 3. File system syncing the change in the Docker volume 4. Subsequent GET requests reading the updated data Adding a 100ms delay after all deletions complete ensures file system changes propagate before tests continue, preventing race conditions where tests check for deletion immediately and find stale data. This should resolve the 6 failing REST tests in CI that were finding leftover data after calling _after() for cleanup.
1 parent 9f4382a commit fa36608

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/helper/ApiDataFactory.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ class ApiDataFactory extends Helper {
256256
for (const factoryName in this.created) {
257257
this.created[factoryName] = []
258258
}
259+
// Add a small delay to ensure file system changes propagate in Docker environments
260+
// This helps avoid race conditions where GET requests after DELETE don't see the changes yet
261+
return new Promise(resolve => setTimeout(resolve, 100))
259262
})
260263
}
261264

test/data/rest/db.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"posts":[{"id":1,"title":"json-server","author":"davert"}],"user":{"name":"davert"}}
1+
{"comments":[],"posts":[{"id":1,"title":"json-server","author":"davert"}]}

0 commit comments

Comments
 (0)