Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode Breakpoints work in test file but not in source files (via vscode-jest and jest/bin/jest) #439

Closed
nathanwinder opened this issue Jan 22, 2020 · 1 comment
Labels
kind: support Asking for support with something or a specific use case scope: integration Related to an integration, not necessarily to core (but could influence core)

Comments

@nathanwinder
Copy link

Current Behavior

When I debug my tests using VS Code and vscode-jest the breakpoints in the *.test.ts trigger but the breakpoints in the src *.ts files do not trigger. The breakpoint is a gray circle and states "Breakpoint ignored because generated code not found (source map problem?)".

Expected behavior

Breakpoints should be enabled for all source

Suggested solution(s)

Additional context

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "name": "vscode-jest-tests",
      "request": "launch",
      "program": "${workspaceFolder}/node_modules/jest/bin/jest",
      "args": ["--runInBand"],
      "cwd": "${workspaceFolder}",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "disableOptimisticBPs": true,
      "sourceMaps": true
    }
  ]
}

package.json

{
...
 "jest": {
    "transform": {
      ".(ts|tsx)": "ts-jest"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
    ],
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ],
    "collectCoverage": true,
    "collectCoverageFrom": [
      "src/**/*.{ts,tsx}"
    ],
    "testMatch": [
      "<rootDir>/**/*.(spec|test).{ts,tsx}"
    ],
    "testURL": "http://localhost",
    "rootDir": ".",
    "watchPlugins": [
      "jest-watch-typeahead/filename",
      "jest-watch-typeahead/testname"
    ]
  }
}

Your environment

Software Version(s)
TSDX ^0.12.3
TypeScript ^3.7.5 vs-code version being used: 3.7.3
Browser n/a
npm/Yarn NPM 6.9.0
Node v10.16.3
Operating System Windows 10
@nathanwinder nathanwinder changed the title Break points work in test file but not in source files Breakpoints work in test file but not in source files Jan 22, 2020
@agilgur5 agilgur5 added the scope: integration Related to an integration, not necessarily to core (but could influence core) label Mar 11, 2020
@agilgur5
Copy link
Collaborator

agilgur5 commented Mar 18, 2020

So I don't use vscode-jest or the integrated debugger much, but was able to get breakpoints to work without much fuss in #577 (comment)

Notably I wasn't using vscode-jest there. But you're actually not using TSDX at all here when running your tests -- your program is ${workspaceFolder}/node_modules/jest/bin/jest.
That means the problem you're facing with breakpoints isn't related to TSDX as you're not using it for testing.

To use tsdx test you'd have to have ${workspaceFolder}/node_modules/tsdx/dist/index.js (and a test arg) as in the linked comment above.
It might also work with vscode-jest if you set it as the pathToJest, but idk

@agilgur5 agilgur5 added the kind: support Asking for support with something or a specific use case label Mar 18, 2020
@agilgur5 agilgur5 changed the title Breakpoints work in test file but not in source files VSCode Breakpoints work in test file but not in source files (via vscode-jest and jest/bin/jest) Mar 18, 2020
@agilgur5 agilgur5 changed the title VSCode Breakpoints work in test file but not in source files (via vscode-jest and jest/bin/jest) VSCode Breakpoints work in test file but not in source files (via vscode-jest and jest/bin/jest) Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: support Asking for support with something or a specific use case scope: integration Related to an integration, not necessarily to core (but could influence core)
Projects
None yet
Development

No branches or pull requests

2 participants