Skip to content

Commit

Permalink
fix flaky jwt test (#10745)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvilums authored May 1, 2024
1 parent 303f86a commit fd45c67
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/js/third_party/jsonwebtoken/issue_147.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit fd45c67

Please sign in to comment.