diff --git a/.github/workflows/bun-testing.yml b/.github/workflows/bun-testing.yml new file mode 100644 index 0000000..0b472d3 --- /dev/null +++ b/.github/workflows/bun-testing.yml @@ -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 diff --git a/.github/workflows/jest-testing.yml b/.github/workflows/jest-testing.yml deleted file mode 100644 index 1671cd4..0000000 --- a/.github/workflows/jest-testing.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Run Jest 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: | - yarn - yarn test | tee ./coverage.txt && exit ${PIPESTATUS[0]} - - name: Jest Coverage Comment - # Ensures this step is run even on previous step failure (e.g. test failed) - if: always() - uses: MishaKav/jest-coverage-comment@main - with: - coverage-summary-path: coverage/coverage-summary.json - junitxml-path: junit.xml - junitxml-title: JUnit - coverage-path: ./coverage.txt diff --git a/bun.lockb b/bun.lockb index 93d6837..e989cba 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 5d19039..328c5b5 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -82,5 +82,6 @@ "extends": [ "@commitlint/config-conventional" ] - } + }, + "packageManager": "bun@1.0.23" } diff --git a/tests/main.test.ts b/tests/main.test.ts index 951f063..fa1e1ce 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -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, })); @@ -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: "",