Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): remove need for typesVersions breaking VSCode imports #130

Merged
merged 15 commits into from
Mar 6, 2024
Prev Previous commit
Next Next commit
fixes
  • Loading branch information
charlypoly committed Mar 5, 2024
commit e5990352f37fcf9edd15f24830b07c0674a17e47
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"/tests/",
"node_modules/",
"coverage/",
"",
"dist/",
"package-lock.json"
],
"overrides": [
Expand Down
2 changes: 1 addition & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import { isDebugEnabled } from "./utils";

// source: https://github.com/csquared/node-logfmt/blob/master/lib/stringify
// source: https://github.com/csquared/node-logfmt/blob/master/lib/stringify.js
function fmtData(data: any): string {
var line = "";

Expand Down
8 changes: 4 additions & 4 deletions tests/awaitResult.spec.ts → tests/awaitResult.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { awaitResult, defer } from "../src";
import { DeferError } from "../src/errors";
import { makeHTTPClient } from "../src/httpClient";
import { DeferError } from "../src/backend";
import { makeHTTPClient } from "../src/backend/remote/httpClient";
import { jitter } from "../src/jitter";

jest.mock("../src/httpClient");
jest.mock("../src/backend/remote/httpClient");
jest.mock("../src/jitter");
jest.setTimeout(20000);

Expand Down Expand Up @@ -57,7 +57,7 @@ describe("awaitResult(deferFn)", () => {

const awaitable = awaitResult(deferred);
const result = await awaitable("");
expect(result).toEqual("coucou");
expect(result).toEqual("Hello World!");
expect(myFunction).not.toHaveBeenCalled();
});
});
Expand Down
21 changes: 10 additions & 11 deletions tests/next/asNextRoute.spec.ts → tests/next/asNextRoute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import helloWorld from "./fixtures/helloWorld";
import { POST, GET } from "./fixtures/route";
import { POST as POSTWithProxy } from "./fixtures/routeWithProxy";
import { getExecution } from "../../src/index";
import { APIError } from "../../src/errors";
import { ExecutionNotFound } from "../../src/backend";

jest.mock("./fixtures/helloWorld");
jest.mock("../../src/index", () => {
Expand All @@ -19,7 +19,7 @@ describe("asNextRoute()", () => {
describe("POST() - background function invocation", () => {
describe("valid empty params, without proxy", () => {
beforeEach(() =>
jest.mocked(helloWorld).mockResolvedValue({ id: "test-id" })
jest.mocked(helloWorld).mockResolvedValue({ id: "test-id" } as any)
);

test("properly call the background function and forward the execution ID", async () => {
Expand All @@ -36,13 +36,13 @@ describe("asNextRoute()", () => {
expect(helloWorld).toHaveBeenCalledWith();

expect(res.status).toBe(200);
expect(await reson()).toEqual({ id: "test-id" });
expect(await res.json()).toEqual({ id: "test-id" });
});
});

describe("valid params, without proxy", () => {
beforeEach(() =>
jest.mocked(helloWorld).mockResolvedValue({ id: "test-id" })
jest.mocked(helloWorld).mockResolvedValue({ id: "test-id" } as any)
);
afterEach(() => {
jest.mocked(helloWorld).mockReset();
Expand All @@ -62,13 +62,13 @@ describe("asNextRoute()", () => {
expect(helloWorld).toHaveBeenCalledWith("charly");

expect(res.status).toBe(200);
expect(await reson()).toEqual({ id: "test-id" });
expect(await res.json()).toEqual({ id: "test-id" });
});
});

describe("valid params, with proxy", () => {
beforeEach(() =>
jest.mocked(helloWorld).mockResolvedValue({ id: "test-id" })
jest.mocked(helloWorld).mockResolvedValue({ id: "test-id" } as any)
);

test("properly call the background function with params and forward the execution ID", async () => {
Expand All @@ -85,7 +85,7 @@ describe("asNextRoute()", () => {
expect(helloWorld).toHaveBeenCalledWith("prefix-charly");

expect(res.status).toBe(200);
expect(await reson()).toEqual({ id: "test-id" });
expect(await res.json()).toEqual({ id: "test-id" });
});
});
});
Expand All @@ -104,7 +104,7 @@ describe("asNextRoute()", () => {
"valid query params, invalid execution ID",
"?id=not-found-id",
"not-found-id",
new APIError("execution not found", ""),
new ExecutionNotFound("execution not found"),
[500, { error: "Error: execution not found", id: "not-found-id" }],
],
[
Expand All @@ -129,8 +129,7 @@ describe("asNextRoute()", () => {
throw executionResult;
});
} else {
// @ts-expect-error unflexible TS \o/
jest.mocked(getExecution).mockResolvedValue(executionResult);
jest.mocked(getExecution).mockResolvedValue(executionResult as any);
}
});
afterEach(() => {
Expand All @@ -152,7 +151,7 @@ describe("asNextRoute()", () => {
}

expect(res.status).toBe(expectedResponseStatus);
expect(await reson()).toEqual(expectedResponseBody);
expect(await res.json()).toEqual(expectedResponseBody);
});
}
);
Expand Down
2 changes: 1 addition & 1 deletion tests/next/fixtures/routeWithProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import helloWorld from "./helloWorld";
const { GetHandler, PostHandler } = asNextRoute(helloWorld, {
// @ts-expect-error too strict return type
async proxy(request) {
const args = await requeston();
const args = await request.json();
return [`prefix-${args[0]}`];
},
});
Expand Down
File renamed without changes.
17 changes: 8 additions & 9 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "./tsconfig.json",
"exclude": [
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/test/**/*",
"scripts/**/*"
]
}

"extends": "./tsconfig.json",
"exclude": [
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/test/**/*",
"scripts/**/*"
]
}
Loading