From 85bec52003e89e1e82e1e3a7f2b3e7839f3ef434 Mon Sep 17 00:00:00 2001 From: "d.kholstinin" Date: Tue, 7 Oct 2025 13:24:22 +0500 Subject: [PATCH] test: fix http undici tests --- .github/workflows/pull-request.yml | 41 +++++++++++++++++++ .github/workflows/size.yml | 17 -------- .../plugin-protocol-http/src/http.spec.ts | 10 ++++- 3 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/pull-request.yml delete mode 100644 .github/workflows/size.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..b4ba78f --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,41 @@ +name: pull-request + +on: + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.TRAMVAI_GH_PAGES_PAT }} + + - uses: actions/setup-node@v4 + with: + node-version: 20.x + registry-url: "https://registry.npmjs.org" + + - name: Install dependencies + run: yarn bootstrap + + - name: Build packages + run: yarn build + + - name: Test packages + run: yarn test + + size: + runs-on: ubuntu-latest + env: + CI_JOB_NUMBER: 1 + steps: + - uses: actions/checkout@v4 + + - uses: andresz1/size-limit-action@v1 + with: + github_token: ${{ secrets.TRAMVAI_GH_PAGES_PAT }} diff --git a/.github/workflows/size.yml b/.github/workflows/size.yml deleted file mode 100644 index bfe2f6b..0000000 --- a/.github/workflows/size.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Size -on: - pull_request: - branches: - - master - -jobs: - size: - runs-on: ubuntu-latest - env: - CI_JOB_NUMBER: 1 - steps: - - uses: actions/checkout@v4 - - - uses: andresz1/size-limit-action@v1 - with: - github_token: ${{ secrets.TRAMVAI_GH_PAGES_PAT }} diff --git a/packages/plugin-protocol-http/src/http.spec.ts b/packages/plugin-protocol-http/src/http.spec.ts index c8180f7..be4f9a3 100644 --- a/packages/plugin-protocol-http/src/http.spec.ts +++ b/packages/plugin-protocol-http/src/http.spec.ts @@ -1,7 +1,15 @@ +const fetch = jest.fn(); + +jest.mock('undici', () => { + return { + ...jest.requireActual('undici'), + fetch: fetch + }; +}); + import { Context, Status } from '@tinkoff/request-core'; import http from './http'; -const fetch = jest.spyOn(globalThis, 'fetch'); const plugin = http(); const next = jest.fn();