swc-project / jest

Super-fast alternative for babel-jest or ts-jest without type checking. Please use main repository for issues
757 stars 37 forks source link

jest.mock is not working if import something from "@jest/globals" #172

Open lionskape opened 5 months ago

lionskape commented 5 months ago

Hi.

Note: I have read that article: https://github.com/swc-project/swc/issues/7435

I faced with some issues here:

  1. I disabled globals injection in Jest (in favor of explicit import from "@jest/globals" to avoid types collision. I also have e2e testing framework which uses global types for it/describe and it is different). https://jestjs.io/docs/cli#--injectglobals
  2. I tried to use jest.mock function to create an automatic mock for module (automatically wrap exports with jest.fn())
  3. Found that jest.mock is not working properly

Looks like similar issue was described here: https://github.com/swc-project/jest/issues/120 So, reproducing case is the same (https://github.com/Smrtnyk/swc-jest-globals-repro)