Skip to content

[bug] Doesn't work with git worktrees #435

Open
@rbsummers

Description

@rbsummers

Describe the bug
I'm experiencing something similar to what #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:

  1. Have repo with test runner configured
  2. Make worktree of the repo. Will need a second branch, git won't let you check out the same branch twice across worktrees
  3. Run command on worktree
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions