Sourcemap support when debugging (Intellij IDEA / Webstorm / others)
See original GitHub issueWhen debugging Jest tests in IDEA I set breakpoints but they are never triggered. I assume this is related to sourcemaps somehow.
Jest correctly gives Typescript filename+line when reporting errors / expect failures, so at this level sourcemaps are working.
This is more of a request for help than bug report. Do people have debugging fully working in your preferred IDE when running Jest tests?
For info, Jetbrains recently released integrated Jest support with progress bar, etc.
Here is the full command executed by IDEA:
"C:\Program Files\nodejs\node.exe" --debug-brk=7830 --expose_debug_as=v8debug C:\Users\alfie\gb\gb-util\node_modules\jest\bin\jest --config "{\"transform\":{\".ts$\":\"<rootDir>/node_modules/ts-jest/dist/preprocessor.js\"},\"testRegex\":\"(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$\",\"moduleFileExtensions\":[\"ts\",\"tsx\",\"js\"],\"rootDir\":\"C:\\Users\\alfie\\gb\\gb-util\",\"transformIgnorePatterns\":[\"/node_modules/\",\"^C:\\Program Files (x86)\\JetBrains\\IntelliJ IDEA 171.3780.15\\plugins\\JavaScriptLanguage\\helpers\"]}" --no-cache --runInBand --colors --setupTestFrameworkScriptFile "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 171.3780.15\plugins\JavaScriptLanguage\helpers\jest-intellij\lib\jest-intellij-jasmine.js" --testPathPattern ^C:\\Users\\alfie\\gb\\gb\-util\\src\\misc\\FlexibleIterator\.spec\.ts$ --testNamePattern "^Flexible iterator Should yield last item after sub\-iterator$"
tsconfig.js:
{
"compilerOptions": {
"jsx": "react",
"module": "commonjs",
"experimentalDecorators": true,
"outDir": "./build",
"preserveConstEnums": true,
"compileOnSave": true,
"removeComments": true,
"sourceMap": true,
"inlineSources": true,
"target": "es6",
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"noUnusedLocals": true
},
"exclude": [
"node_modules",
"build"
]
}
package.json:
{
"name": "gb-util",
"author": "Alfie Kirkpatrick",
"version": "1.0.0",
"description": "Typescript utilities",
"main": "build/index.js",
"typings": "build/index.d.ts",
"license": "UNLICENSED",
"scripts": {
"test": "jest --no-cache"
},
"devDependencies": {
"@types/jest": "^19.2.2",
"jest": "^19.0.2",
"ts-jest": "^19.0.1",
"typescript": "^2.2.1"
},
"jest": {
"transform": {
".ts$": "<rootDir>/node_modules/ts-jest/dist/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
]
},
"unused": {},
"dependencies": {
"global": "^4.3.1"
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:23 (10 by maintainers)
Top Results From Across the Web
Debug code | WebStorm Documentation - JetBrains
WebStorm supports debugging client-side applications running on the built-in or an external web server. Debugging of JavaScript code is only ...
Read more >Stop Painful JavaScript Debug and Embrace Intellij ... - Medium
First, install the JetBrains IDE Support Chrome extension. This will… ... Stop Painful JavaScript Debug and Embrace Intellij with Source Map.
Read more >How to debug TypeScript with breakpoint in Jetbrain IDE?
As "Node parameters", use --require source-map-support/register . This enables you to get the correct lines while debugging in WebStorm.
Read more >Debugging Server-Side TypeScript With WebStorm
Another way of looking at it, if you can pretend the “Any” type does not ... https://www.jetbrains.com/help/idea/running-and-debugging-TypeScript.html.
Read more >Harald at #GitHubUniverse on Twitter: "@alex_ploner ...
got its deserved logo update and a big version bump: ⏸ Support VSCode's new column breakpoint UI Faster and more accurate source map...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @kulshekhar, thanks for response. Here is a link to minimal test project: https://github.com/jugglingcats/ts-jest-idea
It worked for me too. Example project and readme updated. Many thanks - we’re done here.