Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimon committed Jul 6, 2024
1 parent 77fb5a7 commit fe0079d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
11 changes: 5 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"koa": "^2.14.2",
"koa-bodyparser": "^4.4.1",
"koa-route": "^4.0.0",
"nock": "^13.3.8",
"nock": "^14.0.0-beta.7",
"npm": "^10.2.4",
"prettier": "^3.1.0",
"supertest": "^7.0.0",
Expand Down
11 changes: 5 additions & 6 deletions src/common/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ const INITIAL_SYNC_INTERVAL = 10000; // 10 seconds
const INITIAL_SYNC_INTERVAL_DURATION = 3600000; // 1 hour
const MAX_QUEUE_TIME = 3.6e6; // 1 hour

const fetchWithRetry = fetchRetry(fetch, {
retries: 3,
retryDelay: 1000,
retryOn: [408, 429, 500, 502, 503, 504],
});

class HTTPError extends Error {
public response: Response;

Expand Down Expand Up @@ -107,6 +101,11 @@ export class ApitallyClient {
}

private async makeHubRequest(url: string, payload: any) {
const fetchWithRetry = fetchRetry(fetch, {
retries: 3,
retryDelay: 1000,
retryOn: [408, 429, 500, 502, 503, 504],
});
const response = await fetchWithRetry(this.getHubUrlPrefix() + url, {
method: "POST",
body: JSON.stringify(payload),
Expand Down
2 changes: 1 addition & 1 deletion tests/express/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const testCases = [
testCases.forEach(({ name, getApp }) => {
describe(name, () => {
let app: Express;
let appTest: request.SuperTest<request.Test>;
let appTest: request.Agent;
let client: ApitallyClient;

beforeEach(async () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/fastify/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import { getApp } from "./app.js";

describe("Plugin for Fastify", () => {
let app: FastifyInstance;
let appTest: request.SuperTest<request.Test>;
let appTest: request.Agent;
let client: ApitallyClient;

beforeEach(async () => {
mockApitallyHub();
app = await getApp();
app.printRoutes;
appTest = request(app.server);
client = ApitallyClient.getInstance();
await app.ready();
Expand Down
2 changes: 1 addition & 1 deletion tests/koa/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const testCases = [
testCases.forEach(({ name, router, getApp }) => {
describe(name, () => {
let app: Koa;
let appTest: request.SuperTest<request.Test>;
let appTest: request.Agent;
let client: ApitallyClient;

beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/nestjs/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getApp } from "./app.js";

describe("Middleware for NestJS", () => {
let app: INestApplication;
let appTest: request.SuperTest<request.Test>;
let appTest: request.Agent;
let client: ApitallyClient;

beforeEach(async () => {
Expand Down

0 comments on commit fe0079d

Please sign in to comment.