Skip to content

Commit

Permalink
Try to fix flaky delay tests
Browse files Browse the repository at this point in the history
marcbachmann committed Aug 5, 2024
1 parent e68e418 commit 999ef1c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/basics.spec.js
Original file line number Diff line number Diff line change
@@ -564,7 +564,7 @@ describe("MockAdapter basics", function () {

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

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

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

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

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

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

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

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

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

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

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

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

0 comments on commit 999ef1c

Please sign in to comment.