Skip to content

Commit 80aa3f0

Browse files
committed
fix timing issue with date tests
1 parent ba0804c commit 80aa3f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/shell-bson-parser/src/index.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,14 @@ describe('@mongodb-js/shell-bson-parser', function () {
451451

452452
const actual = parse(input, options);
453453
const expectedDate = new (Date as any)(...args) as Date;
454+
455+
// Sometimes we'll get a millisecond difference between instantiating the dates, so let's correct for that
456+
const millisecondsDiff =
457+
actual.getMilliseconds - expectedDate.getMilliseconds();
458+
expect(Math.abs(millisecondsDiff)).to.be.lessThan(2);
459+
460+
expectedDate.setMilliseconds(actual.getMilliseconds);
461+
454462
expect(actual).to.deep.equal({
455463
getDate: expectedDate.getDate(),
456464
getDay: expectedDate.getDay(),

0 commit comments

Comments
 (0)