Skip to content

diego-aquino/zimic-vi-mock-issue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zimic: vi.mock issue reproduction

This repository is a reproduction of the issue with vi.mock in Zimic.

How to reproduce

  1. Clone this repository:

    git clone [email protected]:diego-aquino/zimic-vi-mock-issue.git
    
  2. Install dependencies:

    pnpm install
    
  3. Run the tests:

    pnpm test
    

The file example.test.ts contains one test case using a simple interceptor to mock a fetch request. Line 4 contains a vi.mock call. The test case should pass, but it fails with the error below. Commenting the vi.mock call makes the test pass.

stderr | tests/example.test.ts
[MSW] The currently registered Service Worker has been generated by a different version of MSW (2.4.3) and may not be fully compatible with the installed version.

It's recommended you update your worker script by running this command:

  • npx msw init <PUBLIC_DIR>

You can also automate this process and make the worker script update automatically upon the library installations. Read more: https://mswjs.io/docs/cli/init.
 ❯ tests/example.test.ts (1)
   ❯ Example tests (1)
     × example

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  tests/example.test.ts > Example tests > example
TypeError: Failed to fetch
 ❯ tests/example.test.ts:38:27
     36|     });
     37|
     38|     const response = await fetch('http://localhost:3000/example');
       |                           ^
     39|     expect(response.status).toBe(200);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published