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

Add new package supporting Edge runtime (eg. Cloudflare Workers) #78

Merged
merged 13 commits into from
Sep 13, 2023
Merged
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [16.x]
fail-fast: false

steps:
Expand All @@ -27,6 +27,7 @@ jobs:
packages/browser/yarn.lock
packages/bunyan/yarn.lock
packages/core/yarn.lock
packages/edge/yarn.lock
packages/js/yarn.lock
packages/koa/yarn.lock
packages/node/yarn.lock
Expand Down
44 changes: 28 additions & 16 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
module.exports = {
coverageDirectory: "coverage",
coveragePathIgnorePatterns: ["node_modules/", "dist/"],
globals: {
"ts-jest": {
tsConfig: "tsconfig.json"
}
},
moduleDirectories: ["node_modules"],
moduleFileExtensions: ["ts", "tsx", "js"],
testEnvironment: "node",
// testMatch: ["**/*.test.ts", '"**/*.test.tsx'],
testRegex: ".test.tsx?$",
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest"
}
projects: [
{
displayName: 'Node',
coverageDirectory: "coverage",
coveragePathIgnorePatterns: ["node_modules/", "dist/"],
moduleDirectories: ["node_modules"],
moduleFileExtensions: ["ts", "js"],
testEnvironment: "node",
testMatch: ["<rootDir>/packages/**/*.test.ts"],
testPathIgnorePatterns: ["/node_modules/", "/dist/", "/packages/edge/"],
transform: {
"^.+\\.ts$": ["ts-jest", "tsconfig.json"]
},
},
{
displayName: 'Edge',
coverageDirectory: "coverage",
coveragePathIgnorePatterns: ["node_modules/", "dist/"],
moduleDirectories: ["node_modules"],
moduleFileExtensions: ["ts", "js"],
testEnvironment: "@edge-runtime/jest-environment",
testMatch: ["<rootDir>/packages/edge/**/*.test.ts"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
transform: {
"^.+\\.ts$": ["ts-jest", "tsconfig.json"]
},
},
]
};
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
"test": "jest"
},
"devDependencies": {
"@types/babel__traverse": "7.0.4",
"@edge-runtime/jest-environment": "^2.3.1",
"@types/babel__core": "7.0.4",
"@types/jest": "^24.0.17",
"@types/babel__traverse": "7.0.4",
"@types/jest": "^29.5.4",
"@types/node": "^12.7.2",
"jest": "^24.9.0",
"jest": "^29.6.4",
"lerna": "^3.16.4",
"prettier": "^1.18.2",
"ts-jest": "^24.0.2",
"ts-node": "^8.3.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
}
}
4 changes: 2 additions & 2 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"nock": "^10.0.6",
"npm-run-all": "^4.1.5",
"ts-loader": "^6.0.4",
"ts-node": "^8.3.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.7"
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@logtail/core": "^0.4.9",
Expand Down
8 changes: 2 additions & 6 deletions packages/browser/src/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("browser tests", () => {
// expect(actualValue).toEqual(expectedValue);
// });

it("should echo log if logtail sends 20x status code", async done => {
it("should echo log if logtail sends 20x status code", async () => {
nock("https://in.logtail.com")
.post("/")
.reply(201);
Expand All @@ -35,11 +35,9 @@ describe("browser tests", () => {
const browser = new Browser("valid source token");
const echoedLog = await browser.log(message);
expect(echoedLog.message).toEqual(expectedLog.message);

done();
});

it("should throw error if logtail sends non 200 status code", async done => {
it("should throw error if logtail sends non 200 status code", async () => {
nock("https://in.logtail.com")
.post("/")
.reply(401);
Expand All @@ -50,7 +48,5 @@ describe("browser tests", () => {
});
const message: string = String(Math.random);
await expect(browser.log(message)).rejects.toThrow();

done();
});
});
Loading