Skip to content

Commit 3e74fae

Browse files
authored
fix backend test failing (Allow 10ms margin of error)
1 parent b44259a commit 3e74fae

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

backend/test/unit/enrichment-service/proxycurl/client.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
22

3-
import { Logger } from 'winston';
43
import axios from 'axios';
4+
import { Logger } from 'winston';
55
import ProxycurlApi, {
66
ReverseEmailLookupParams,
77
ReverseEmailLookupResponse
@@ -114,8 +114,9 @@ describe('ProxycurlApi', () => {
114114
const end = Date.now();
115115

116116
const duration = end - start;
117+
const tolerance = 10; // Allow a 10ms margin of error to account for slight timing variations
117118

118-
expect(duration).toBeGreaterThanOrEqual(1000);
119+
expect(duration).toBeGreaterThanOrEqual(1000 - tolerance);
119120
expect(mockAxiosInstance.get).toHaveBeenCalledTimes(10);
120121
});
121122
});

backend/test/unit/enrichment-service/thedig/client.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('ThedigApi', () => {
9898
const end = Date.now();
9999

100100
const duration = end - start;
101-
const tolerance = 0; // Allow a 10ms margin of error to account for slight timing variations
101+
const tolerance = 10; // Allow a 10ms margin of error to account for slight timing variations
102102

103103
expect(duration).toBeGreaterThanOrEqual(1000 - tolerance);
104104
expect(mockAxiosInstance.post).toHaveBeenCalledTimes(10);
@@ -170,8 +170,9 @@ describe('ThedigApi', () => {
170170
const end = Date.now();
171171

172172
const duration = end - start;
173+
const tolerance = 10; // Allow a 10ms margin of error to account for slight timing variations
173174

174-
expect(duration).toBeGreaterThanOrEqual(1000);
175+
expect(duration).toBeGreaterThanOrEqual(1000 - tolerance);
175176
expect(mockAxiosInstance.post).toHaveBeenCalledTimes(10);
176177
});
177178

backend/test/unit/enrichment-service/voilanorbert/client.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
jest
88
} from '@jest/globals';
99

10-
import { Logger } from 'winston';
1110
import axios from 'axios';
11+
import { Logger } from 'winston';
1212
import VoilanorbertApi from '../../../../src/services/enrichment/voilanorbert/client';
1313
import { logError } from '../../../../src/utils/axios';
1414

@@ -93,8 +93,9 @@ describe('VoilanorbertApi', () => {
9393
const end = Date.now();
9494

9595
const duration = end - start;
96+
const tolerance = 10; // Allow a 10ms margin of error to account for slight timing variations
9697

97-
expect(duration).toBeGreaterThanOrEqual(1000);
98+
expect(duration).toBeGreaterThanOrEqual(1000 - tolerance);
9899
expect(axios.create().post).toHaveBeenCalledTimes(10);
99100
});
100101

0 commit comments

Comments
 (0)