Skip to content

Commit

Permalink
chore: changed tests to use bun
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Mar 7, 2024
1 parent 03c047e commit 97dd67a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 41 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/bun-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run Bun testing suite
on:
workflow_dispatch:
pull_request_target:
types: [ opened, synchronize ]

env:
NODE_ENV: "test"

jobs:
testing:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: '20.10.0'
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Build & Run test suite
run: |
bun i
bun test --coverage
33 changes: 0 additions & 33 deletions .github/workflows/jest-testing.yml

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"prepare": "husky install",
"deploy": "wrangler deploy",
"worker": "wrangler dev --port 8787",
"proxy": "tsx src/proxy.ts",
"test": "jest --setupFiles dotenv/config --coverage"
"proxy": "tsx src/proxy.ts"
},
"keywords": [
"typescript",
Expand All @@ -46,6 +45,7 @@
"@cspell/dict-software-terms": "^3.3.17",
"@cspell/dict-typescript": "^3.1.2",
"@mswjs/data": "0.16.1",
"@types/bun": "1.0.8",
"@types/jest": "29.5.12",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
Expand Down Expand Up @@ -82,5 +82,6 @@
"extends": [
"@commitlint/config-conventional"
]
}
},
"packageManager": "[email protected]"
}
8 changes: 3 additions & 5 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { afterAll, afterEach, beforeAll, describe, expect, it, jest } from "@jest/globals";
jest.mock("@octokit/webhooks", () => ({
...(jest.requireActual("@octokit/webhooks") as object),
import { afterAll, afterEach, beforeAll, describe, expect, it, jest, mock, spyOn } from "bun:test";
mock.module("@octokit/webhooks", () => ({
Webhooks: WebhooksMocked,
}));

Expand Down Expand Up @@ -41,13 +40,12 @@ afterEach(() => {
});
afterAll(() => {
server.close();
jest.restoreAllMocks();
});

describe("Worker tests", () => {
it("Should fail on missing env variables", async () => {
const req = new Request("http://localhost:8080");
const consoleSpy = jest.spyOn(console, "error").mockImplementation(() => jest.fn());
const consoleSpy = spyOn(console, "error").mockImplementation(() => jest.fn());
const res = await worker.fetch(req, {
WEBHOOK_SECRET: "",
APP_ID: "",
Expand Down

0 comments on commit 97dd67a

Please sign in to comment.