jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.83k stars 290 forks source link

Feature: open typescript file #850

Open KermanX opened 2 years ago

KermanX commented 2 years ago

Environment

  1. vscode-jest version: 4.3.1
  2. node -v: v14.16.0
  3. npm -v: 8.6.0
  4. npm ls jest :
    +-- jest@27.5.1
    `-- ts-jest@27.1.4
    `-- jest@27.5.1 deduped
  5. your vscode-jest settings if customized: no
  6. Operating system: Windows10 21H1

Prerequisite

Steps to Reproduce

  1. Create a test TypeScript file like index.test.ts.
  2. Add a test to it which always fails.
  3. Compile it by tsc with configuration that tells tsc to generate .js.map file.
  4. Now we have index.test.js and index.test.js.map.
  5. Run the index.test.js in a certain way (any way) by vscode-jest.
  6. Click this button: image
  7. Vscode jumps to index.test.js instead of index.test.ts, not scanning the source map file.

Expected Behavior

Scan the source map file.

Actual Behavior

Not scanning the source map file.

☆Why should it be like this

In vscode, using a monorepo, it is very common to use ctrl+left click to jump to something defined in a ts file in another package.

However, since "the another package" is installed by a link in `/node_modules/", and that file is actually a compiled js file, vscode scans the .js.map file, and jumps to the ts file recorded in map file that is the real source file.

So in my opinion, it won't be difficult for vscode-jest to have this feature if using something has already been implemented by vscode.

connectdotz commented 2 years ago

if your project is a typescript project, you might find using jest with typescript a much more intuitive way for setting up your development environment, which you do not need to deal with the .js files at all and can debug/view the ts file directly...

KermanX commented 2 years ago

if your project is a typescript project, you might find using jest with typescript a much more intuitive way for setting up your development environment, which you do not need to deal with the .js files at all and can debug/view the ts file directly...

Thanks for your help.

In fact, I use jest in this way months ago, but it seemed to be too complex to deal with jest,babel,tsc,monorepo,esm,typesciptetc together.😭

So I had to run jest through my own cli...

Thanks again.