vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
12.87k stars 1.15k forks source link

Unable to debug a dependency that contains only typescript source files #6234

Open josh-burton opened 2 months ago

josh-burton commented 2 months ago

Describe the bug

I have a few internal dependencies that only contain typescript source files - no compiled javascript.

Until this point I've been using jest, and compilation and debugging these files has worked fine.

When migrating to vitest, compilation works, but I'm unable to set break points within these files.

Is there any config required to allow debugging the typescript source?

Reproduction

A nodejs typescript project compiling a published typescript package, built with tsc --noEmit.

A debug breakpoint set within the published typescript package is not hit.

System Info

IDE: Intellij IDEA

  System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 130.06 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
    pnpm: 8.4.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 126.0.6478.185
    Safari: 17.5
  npmPackages:
    vite: ^5.3.4 => 5.3.4 
    vitest: ^2.0.4 => 2.0.4

Used Package Manager

npm

Validations

github-actions[bot] commented 2 months ago

Hello @josh-burton. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

josh-burton commented 2 months ago

I'm unsure how to create a reproducible sample using stackblitz as I would need to publish another package to demonstrate that debugging does not work.

Is there a way to replicate publishing a package without actually publishing a package to npm?

AriPerkkio commented 2 months ago

You can also create

a minimal reproduction using a GitHub repository

and there have manually created node_modules which contains the package that demonstrates the issue. It doesn't have to be published package, just create it under node_modules and commit the changes to git remote.

josh-burton commented 2 months ago

You can also create

a minimal reproduction using a GitHub repository

and there have manually created node_modules which contains the package that demonstrates the issue. It doesn't have to be published package, just create it under node_modules and commit the changes to git remote.

ok thanks :) I'll do that.

josh-burton commented 2 months ago

@AriPerkkio I've created a reproducible sample here: https://github.com/josh-burton/vitest-debugging-bug

Are you able to reopen the issue?

The sample project has:

If a breakpoint is set inside index.test.ts, it is hit when debugging:

Screenshot 2024-08-06 at 9 15 49 AM

If a breakpoint is set inside of node_modules/my_dependency/src/repository/my_repository, it is never hit when debugging:

Screenshot 2024-08-06 at 9 16 44 AM

Some notes:

josh-burton commented 2 months ago

I've also filed a Youtrack issue for IntelliJ: https://youtrack.jetbrains.com/issue/IDEA-357178/vitest-unable-to-hit-debug-breakpoint-inside-a-nodemodules-dependency