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

Examples comparing ts-jest and Jest setups #118

Merged
merged 1 commit into from
Mar 1, 2017

Conversation

tkrotoff
Copy link
Contributor

@tkrotoff tkrotoff commented Mar 1, 2017

Following this discussion

The Jest example works with vscode debugger
The ts-jest example does not work with vscode debugger - I don't know how to make it work in an elegant way

The Jest example works with vscode
The ts-jest example does not work with vscode
@tkrotoff tkrotoff mentioned this pull request Mar 1, 2017
@kulshekhar kulshekhar merged commit 643a78f into kulshekhar:master Mar 1, 2017
@kulshekhar
Copy link
Owner

@tkrotoff thanks!

@kulshekhar
Copy link
Owner

The Jest example works with vscode
The ts-jest example does not work with vscode - I don't know how it to make it work

I tested the examples from the command line and they worked there. I think adding these in despite the issue with vscode would be better than not adding them.

@tkrotoff
Copy link
Contributor Author

tkrotoff commented Mar 1, 2017

Well, before merging this, I wanted you to review it and discuss it with you and see how to make ts-jest work with vscode debugger.

If you check carefully the examples, I don't see any benefit for using ts-jest over Jest directly (with a tsc pre-task).

I though ts-jest would allow me to remove the tsc pre-task but then vscode debugger won't work.

Overall, I don't understand what problem ts-jest is trying to solve and the readme does not help on this.

Edit, clarification:
I consider that setting breakpoints and debugging my tests written in TypeScript is a must have feature.
I don't see how people could develop something bigger than an "hello world" without this feature.
Why examples with vscode debugger? it is the most popular editor (from what I've seen) when writing in TypeScript.

@kulshekhar
Copy link
Owner

kulshekhar commented Mar 1, 2017

@tkrotoff ok. I misunderstood what you were trying to say.

The reason I created ts-jest was solely because I wanted sourcemap support for tests written in typescript. The only way to see this issue is by introducing a bug in a typescript file in a part that is covered by a test. Without ts-jest, at least when I had tried, the tests failed with line numbers based on the transpiled javascript file and not the original typescript files.

Does this bring some clarity?

As for vscode, even though that is what I use, integration with it wasn't a priority for me. Neither was coverage, for that matter.

Should I now revert this merge?

@kulshekhar
Copy link
Owner

Looking at this again, merging was probably hastily done. I'll revert this now and look at this again later

@tkrotoff
Copy link
Contributor Author

tkrotoff commented Mar 2, 2017

Without ts-jest [...] the tests failed with line numbers based on the transpiled javascript file and not the original typescript files

I see, that matches the README.md line: be able to locate errors.

As for vscode [...] integration with it wasn't a priority for me.

Approaches to solve the problem:

  • Tell vscode where the generated .js (+ source map) files are thx to cacheDirectory - in practice this does not work
    ts-jest could write down in a special directory known to vscode the generated *.js files

  • ts-jest does not generate the .js files: a pre-task does the job instead and ts-jest just returns the previously generated .js files to Jest for the line numbers to be OK

Edit:
This is not specific to vscode. Jest cannot be debugged when using a source map preprocessor => any debugger need to have access to the generated *.js files.

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

Successfully merging this pull request may close these issues.

None yet

2 participants