You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The unit test for settling debt is currently non-deterministic, likely due to floating point arithmetic issues
Avoid floating point arithmetic by measuring currency amounts in integers instead of floating points
Switch the unit from pounds (GBP) to pence (GBX)
See example of non-deterministic test runs here (screenshot below):
Test Code
// Check whether we can settle a debt between two users.test("POST /debts/settle",async()=>{constserver=supertest(app);awaitserver.post("/debts/settle").send({from: "testuser456",to: "testuser123",amount: 50,}).expect(200);// Check whether the debt was successfully reduced by 50.awaitdebtModel.findOne({from: "testuser123",to: "testuser456",}).then((debt)=>{expect(debt.amount).toBe(50);});});
Summary
Test Code