sheremet-va/vi-fetch

[Bug] After run vi-fetch to mock the server, the node process occupy 100% CPU

harrytran998 opened this issue · 2 comments

Hi @sheremet-va, thanks for your great lib. But today I tried this with the code below with vitest run, but it seems the node server cannot stop there. Can you take a look at this problem?

import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import { prepareFetch, createMockApi } from 'vi-fetch';
import { generateApi } from '../src/base.service';

beforeAll(() => {
  prepareFetch();
});

const baseUrl = 'http://localhost:3000';

describe('ClientBuilder generate API correctly', () => {
  const { mockFetch, mockGet } = createMockApi({ baseUrl });
  const client = generateApi(baseUrl, {
    headers: {
      'X-Factor': 'Factor'
    }
  });

  beforeEach(() => {
    mockFetch.clearAll();
  });

  it('GET request', async () => {
    mockGet('/acquisitions').willResolve({ acquisitions: 'acquisitions' });
    const response = await client.acquisitions.get();
    expect(response).toStrictEqual({ acquisitions: 'acquisitions' });
  });
});

Sorry, but there is not enough information. Please, create a reproduction, using https://vitest.new

Sorry about this. After hours of tracing, it is not for your wonderful lib. Because I use monorepo, so have some problems with scanning files --> 100% CPU.

Thanks for your quick reply.