rstest icon indicating copy to clipboard operation
rstest copied to clipboard

[Bug]: `rs.mock()`doesn't load barrel files

Open AndyOGo opened this issue 2 months ago • 1 comments

Version

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (2) x64 AMD EPYC
    Memory: 2.25 GB / 4.01 GB
    Container: Yes
    Shell: Unknown
  npmPackages:
    @rstest/core: 0.5.1 => 0.5.1

Details

Calling rs.mock() on folders of re-exporting barrel files does not work.

npm test

> [email protected] test
> rstest

  Rstest v0.5.1

 ✓ src/reproduction-fixed.test.ts (1)

Summary of all failing tests:

 FAIL  src/reproduction.test.ts 
Error: Cannot find module './__mocks__/common'

No error stack found, set 'DEBUG=rstest' to show fullStack.

 Test Files 1 failed | 1 passed (2)
      Tests 1 passed
   Duration 839ms (build 33ms, tests 806ms)

Workaround

Replace rs.mock("./foo") by rs.mock("./foo/index").

Reproduce link

https://codesandbox.io/p/devbox/zen-violet-whwqhf?workspaceId=ws_AUrTGk3RTnAN4nJ64LUUVP

Reproduce Steps

  1. go to https://codesandbox.io/p/devbox/zen-violet-whwqhf?workspaceId=ws_AUrTGk3RTnAN4nJ64LUUVP
  2. run npm test

AndyOGo avatar Oct 13 '25 10:10 AndyOGo

This is a bug when rstest resolve mock path, we will fix it as soon as possible

9aoy avatar Nov 06 '25 08:11 9aoy