swc-project / swc-project/swc-node

Debugger will not stop at break points when using swc-jest

Open
#656 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2k
Forks
95
Avg merge
14d 11h
Merged PRs (30d)
1

Description

I think that this is because source maps must be generated inline.

A fix for this was proposed in #632, which set's the source map as inline for jest if it is undefined however it is not undefined by default.

I'm configuring jest in package.json using the preset

"jest": {
    "preset": "@swc-node/jest",
    ...
}

A workaround is to set it manually

"jest": {
  "transform": {
    "^.+\\.(t|j)sx?$": [
      "@swc-node/jest",
      {
        "swc": {
          "sourceMaps": "inline"
        }
      }
    ]
  },
  ...
}

I notice that when reading tsconfig it is given a default value. This may be the problem.

https://github.com/swc-project/swc-node/blob/8c180e68abbc66aa68f83b401d985a6c8617baa9/packages/register/read-default-tsconfig.ts#L99-L107

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the swc-jest preset configuration with the workaround in package.json, then inspect the defaults around lines 99–107 of packages/register/read-default-tsconfig.ts and the change proposed in issue #632. Reproduce the breakpoint failure with the shown Jest setup and verify that debugging stops at the original TypeScript source without requiring manual inline source-map configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.