test-runner
test-runner copied to clipboard
[bug] Doesn't work with git worktrees
Describe the bug
I'm experiencing something similar to what https://github.com/storybookjs/test-runner/issues/415 showed: whenever I run the test runner, the console starts spitting errors about jest-haste-map
with references to folders that are outside of the repo.
$ test-storybook
jest-haste-map: duplicate manual mock found: <some function name>
The following files share their name; please delete one of them:
* <rootDir>/<path to some file that is not on the repo>
* <rootDir>/<path to some file that is not on the repo> # same file, but from different worktrees
# ... or either ...
jest-haste-map: Haste module naming collision: <some module name>
The following files share their name; please adjust your hasteImpl:
* <rootDir>/<path to some file that is not on the repo>
* <rootDir>/<path to some file that is not on the repo> # same file, but from different worktrees
# same thing many many times with other files and many not from the repo I intended the tests to run
I work in a team with other devs and no one else experiences this. After reading the last comment on the aforementioned issue I realized that tmy setup is slightly different than the rest because I use worktrees, and the problem is likely that the test runner is not finding the expected content inside the .git
folder, as for worktrees this is not a directory but a reference to the main worktree's one.
To Reproduce Steps to reproduce the behavior:
- Have repo with test runner configured
- Make worktree of the repo. Will need a second branch, git won't let you check out the same branch twice across worktrees
- Run command on worktree
- See error
Expected behavior Test runs.
System
Storybook Environment Info:
System:
OS: macOS 14.3
CPU: (10) arm64 Apple M1 Max
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.0 - ~/.asdf/installs/nodejs/20.11.0/bin/node
npm: 10.2.4 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 8.15.2 - ~/.asdf/installs/pnpm/8.15.2/bin/pnpm <----- active
Browsers:
Chrome: 121.0.6167.184
Safari: 17.3
npmPackages:
@storybook/addon-a11y: ^7.6.12 => 7.6.14
@storybook/addon-coverage: ^1.0.0 => 1.0.0
@storybook/addon-designs: ^7.0.9 => 7.0.9
@storybook/addon-essentials: ^7.6.12 => 7.6.14
@storybook/addon-interactions: ^7.6.12 => 7.6.14
@storybook/addon-links: ^7.6.12 => 7.6.14
@storybook/blocks: ^7.6.12 => 7.6.14
@storybook/jest: ^0.2.3 => 0.2.3
@storybook/test: ^7.6.12 => 7.6.14
@storybook/test-runner: ^0.16.0 => 0.16.0
@storybook/testing-library: ^0.2.2 => 0.2.2
@storybook/vue3: ^7.6.12 => 7.6.14
@storybook/vue3-vite: ^7.6.12 => 7.6.14
eslint-plugin-storybook: ^0.6.15 => 0.6.15
storybook: ^7.6.12 => 7.6.14
Additional context
-s
seems to fix the issue.
Hey @rbsummers thanks for reporting this issue. I unfortunately don't have time or mental capacity to investigate this issue. Given you have are deep in it, would you be willing to experiment and provide a PR?
You could take a look into this area of the file in node_modules, and experiment with some changes: https://github.com/storybookjs/test-runner/blob/next/src/config/jest-playwright.ts#L78