Skip to content

Commit 999ef1c

Browse files
committed
Try to fix flaky delay tests
1 parent e68e418 commit 999ef1c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/basics.spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ describe("MockAdapter basics", function () {
564564

565565
it("allows delay in millsecond per request (legacy non-chaining)", function () {
566566
mock = new MockAdapter(instance);
567-
var start = new Date().getTime();
567+
var start = Date.now();
568568
var firstDelay = 100;
569569
var secondDelay = 500;
570570
var success = 200;
@@ -576,14 +576,14 @@ describe("MockAdapter basics", function () {
576576

577577
return Promise.all([
578578
instance.get("/foo").then(function (response) {
579-
var end = new Date().getTime();
579+
var end = Date.now();
580580
var totalTime = end - start;
581581

582582
expect(response.status).to.equal(success);
583583
expect(totalTime).greaterThanOrEqual(firstDelay);
584584
}),
585585
instance.get("/bar").then(function (response) {
586-
var end = new Date().getTime();
586+
var end = Date.now();
587587
var totalTime = end - start;
588588

589589
expect(response.status).to.equal(success);
@@ -594,7 +594,7 @@ describe("MockAdapter basics", function () {
594594

595595
it("allows delay in millsecond per request", function () {
596596
mock = new MockAdapter(instance);
597-
var start = new Date().getTime();
597+
var start = Date.now();
598598
var firstDelay = 100;
599599
var secondDelay = 500;
600600
var success = 200;
@@ -609,14 +609,14 @@ describe("MockAdapter basics", function () {
609609

610610
return Promise.all([
611611
instance.get("/foo").then(function (response) {
612-
var end = new Date().getTime();
612+
var end = Date.now();
613613
var totalTime = end - start;
614614

615615
expect(response.status).to.equal(success);
616616
expect(totalTime).greaterThanOrEqual(firstDelay);
617617
}),
618618
instance.get("/bar").then(function (response) {
619-
var end = new Date().getTime();
619+
var end = Date.now();
620620
var totalTime = end - start;
621621

622622
expect(response.status).to.equal(success);
@@ -626,7 +626,7 @@ describe("MockAdapter basics", function () {
626626
});
627627

628628
it("overrides global delay if request per delay is provided and respects global delay if otherwise", function () {
629-
var start = new Date().getTime();
629+
var start = Date.now();
630630
var requestDelay = 100;
631631
var globalDelay = 500;
632632
var success = 200;
@@ -638,7 +638,7 @@ describe("MockAdapter basics", function () {
638638

639639
return Promise.all([
640640
instance.get("/foo").then(function (response) {
641-
var end = new Date().getTime();
641+
var end = Date.now();
642642
var totalTime = end - start;
643643

644644
expect(response.status).to.equal(success);
@@ -647,7 +647,7 @@ describe("MockAdapter basics", function () {
647647
expect(totalTime).lessThan(globalDelay);
648648
}),
649649
instance.get("/bar").then(function (response) {
650-
var end = new Date().getTime();
650+
var end = Date.now();
651651
var totalTime = end - start;
652652

653653
expect(response.status).to.equal(success);

0 commit comments

Comments
 (0)