rstest
rstest copied to clipboard
[Bug]: `rs.mock()`doesn't load barrel files
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
- go to https://codesandbox.io/p/devbox/zen-violet-whwqhf?workspaceId=ws_AUrTGk3RTnAN4nJ64LUUVP
- run
npm test
This is a bug when rstest resolve mock path, we will fix it as soon as possible