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

The debugger doesn't stop at correct statements in VSCode in source files #484

Closed
trivikr opened this issue Apr 6, 2018 · 22 comments
Closed

Comments

@trivikr
Copy link
Contributor

trivikr commented Apr 6, 2018

  • Issue
    The debugger doesn't stop at correct statements in VSCode in source files

    • VSCode 1.21.1
    • jest 22.4.2
    • ts-jest 22.4.2
    • typescript 2.7.2
  • Expected behavior
    The debugger should stop at correct statements in VSCode for source files

  • Link to a minimal repo that reproduces this issue
    ts-jest-node8-debugger-repro/jest-22-test

    Screen recording

  • Optional (but highly recommended) - Configure Travis (or your favorite system) with the minimal repo
    Done

@trivikr
Copy link
Contributor Author

trivikr commented Apr 6, 2018

Similar issue was discussed in #309
This issue is not reproducible if I remove "collectCoverage": true from Jest Config (code)

@trivikr
Copy link
Contributor Author

trivikr commented Apr 6, 2018

Confirmed that issue is reproducible with latest version ts-jest@22.0.4, and updated repro repo and issue description

@YagoLopez
Copy link

Same problem in Webstorm

@trivikr
Copy link
Contributor Author

trivikr commented Apr 13, 2018

I removed collectCoverage from jest.json and added --coverage in Jest CLI to avoid this bug

@YagoLopez
Copy link

Thanks but no luck in my environment (Create-React-App-Typescript):

// package.json

// ...

  "scripts": {
    "test": "jest --verbose --notify",
    "test:watch": "jest --watch --notify",
    "test:debug": "jest --debug",
    "test:update": "jest -u",
    "coverage": "jest --coverage --silent"
  },
  "jest": {
    "setupFiles": [
      "<rootDir>/config/test-shim.js",
      "<rootDir>/config/test-setup.js"
    ],
    "globals": {
      "ts-jest": {
        "skipBabel": true
      }
    },
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js"
    ],
    "transform": {
      "^.+\\.(ts|tsx)$": "<rootDir>/config/test-preprocessor.js",
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/config/assetsTransformer.js",
      "\\.(css|less)$": "<rootDir>/config/assetsTransformer.js"
    },
    "roots": [
      "src"
    ],
    "testMatch": [
      "**/test/*.(test).(ts|tsx|js)"
    ],
    "collectCoverageFrom": [
      "src/orm/**/*.{js,tsx,ts}",
      "!src/index.tsx",
      "!src/App.tsx",
      "!src/orm/test/models/**"
    ]
  }

// ...

@kulshekhar
Copy link
Owner

I've taken a look at the linked repo and can confirm noticing this issue. I tried debugging a bit but couldn't figure out the root cause.

@YagoLopez
Copy link

Maybe the root cause has more to do with jest itself than with ts-jest

@kulshekhar
Copy link
Owner

The fix for #485 (which seems to be in jest) might fix this but that's just a hunch and not based on any evidence

@YagoLopez
Copy link

YagoLopez commented Apr 14, 2018

Indeed, it seems to be a jest issue
jestjs/jest#5925

@kulshekhar
Copy link
Owner

@YagoLopez thanks for testing that out!

@SimenB
Copy link
Contributor

SimenB commented Apr 15, 2018

Is it jestjs/jest#5739? jestjs/jest#5925 is for thrown errors, not source stepping

@YagoLopez
Copy link

@SimenB that's correct, thanks for the clarification

@nolazybits
Copy link

nolazybits commented Jun 27, 2018

@YagoLopez did you find a workaround?
I have exactly this problem :( but with IntelliJ

screen shot 2018-06-27 at 4 58 28 pm

Thanks

Running the test like
node --inspect-brk=0.0.0.0:5858 ../../node_modules/.bin/jest --no-cache --watch --runInBand

with the following config

module.exports = {
    transform: {
        "^.+\\.(t|j)sx?$": "ts-jest"
    },
    testRegex: "(/tests/.*.(test|spec)).(jsx?|tsx?)$",
    testPathIgnorePatterns: ["/lib/", "/node_modules/"],
    moduleFileExtensions: [
        "ts",
        "tsx",
        "js",
        "jsx",
        "json",
        "node"
    ],
    verbose: true,
    globals: {
        "ts-jest": {
            disableSourceMapSupport: true
        }
    }
}

@YagoLopez
Copy link

Sorry but not. Are you in the latest versions of IntelliJ with all dependencies up to date (jest, ts-jest, etc)? May be that could help but I cannot confirm it.

@nolazybits
Copy link

IntelliJ IDEA 2018.1.5 (Ultimate Edition)
Build #IU-181.5281.24, built on June 13, 2018
JRE: 1.8.0_152-release-1136-b39 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.5
"jest": "23.2.0",
"ts-jest": "22.4.6",

Yeah yarn outdated spits nothing so I should be up to date.

Thanks for answering.

@YagoLopez
Copy link

Take a look at this:
#150 (comment)

And a little of more info here:
http://jestjs.io/docs/en/troubleshooting.html

If you have luck, please report it here.

@huafu
Copy link
Collaborator

huafu commented Jul 5, 2018

Having same issue here, I thought it was related to multiline import statement and/or multiline function (...) header that is why my minimal repo has such weird code, but after putting everything in one line I have still the same issue. @YagoLopez I've also tried setting inlineSourceMap without success (thought it should be the default now - as I am using latest jest and ts-jest).
Notice that running yarn test the throw is shown at correct line number:
screen shot 2018-07-05 at 09 02 35

But if you try to debug in vscode with debugger statement (putting a breakpoint will stop nowhere), it's totally at the wrong line:
screen shot 2018-07-05 at 08 43 47

Here is the minimal repo: https://github.com/huafu/issue-ts-jest-wrong-line

FYI my jest cache has been cleared, and I'm using an up to date vscode on latest macOS

@huafu
Copy link
Collaborator

huafu commented Jul 5, 2018

...I've created a new issue #606, because it sounds like a different one from @trivikr – he is using version 22 of jest and ts-jest, while I'm using 23, and when I downgrade ts-jest to version @<23, vscode goes to the correct line, where debugger statement actually is.

@huafu
Copy link
Collaborator

huafu commented Jul 24, 2018

tested as explained by @trivikr, #626 will fix this (tho you MUST remove the babelrc: false from jest config in package.json. (tested with and without coverage)

@huafu
Copy link
Collaborator

huafu commented Aug 3, 2018

fixed in 23.1.2

@huafu huafu closed this as completed Aug 3, 2018
yosriz added a commit to kinecosystem/kin-sdk-node that referenced this issue May 19, 2019
kulshekhar/ts-jest#484 - removing collectCoverage fixed the issue,
in CI the flag in test job should take care of creating coverage.
@agordeev
Copy link

Reproducible on ts-jest 24.0.2 and jest 24.8.0. Removing collectCoverage: true from jest.config.js helped

@antonovicha
Copy link

Here is new issue created #917 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants