diff --git a/test/moments.test.js b/test/moments.test.js index 7cacfc9..16021d6 100644 --- a/test/moments.test.js +++ b/test/moments.test.js @@ -143,7 +143,8 @@ test('moments are private, validated, editable and survive page renumbering as " assert.equal((await post(alice, '/api/moments/delete', { id: spread.id })).status, 200); assert.equal((await get(alice, '/api/moments?m=Moon%20Garden')).moments.length, 1); } finally { - if (child) child.kill(); + // The server writes db.json on SIGTERM; removing the folder before it exits races that write. + if (child && child.exitCode === null) await new Promise(resolve => { child.once('exit', resolve); child.kill(); }); fs.rmSync(root, { recursive: true, force: true }); } });