From fd45c67e72d76f3136c6c311c02cfc9699de2b6f Mon Sep 17 00:00:00 2001 From: Georgijs <48869301+gvilums@users.noreply.github.com> Date: Wed, 1 May 2024 12:00:16 -0700 Subject: [PATCH] fix flaky jwt test (#10745) --- test/js/third_party/jsonwebtoken/issue_147.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/js/third_party/jsonwebtoken/issue_147.test.js b/test/js/third_party/jsonwebtoken/issue_147.test.js index 4b20721ad2c3c..aada99adc6f7f 100644 --- a/test/js/third_party/jsonwebtoken/issue_147.test.js +++ b/test/js/third_party/jsonwebtoken/issue_147.test.js @@ -5,6 +5,8 @@ describe("issue 147 - signing with a sealed payload", function () { it("should put the expiration claim", function () { var token = jwt.sign(Object.seal({ foo: 123 }), "123", { expiresIn: 1000 }); var result = jwt.verify(token, "123"); - expect(result.exp).toBeCloseTo(Math.floor(Date.now() / 1000) + 1000, 0); + const expected = Math.floor(Date.now() / 1000) + 1000; + // check that the expiration is within 1 second of the expected value + expect(result.exp).toBeWithin(expected - 1, expected + 2); }); });