-
Notifications
You must be signed in to change notification settings - Fork 455
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
Breakpoints & sourcemaps do not work with a react native setup in Webstorm #209
Comments
I was able to get the debugger to stop at the breakpoint with the following changes:
"testPathIgnorePatterns": ["/node_modules/", "<rootDir>/src/some-test.test.js"],
"mapCoverage": true, |
Great stuff, I was as well! Thanks a lot for the quick reply @kulshekhar . However, my codebase makes quite a bit of use of default imports, e.g. However - it's not quite that simple. My tests actually start breaking when it is turned off, even when doing a lot of the workarounds described in #92. I've updated the repo at https://github.com/GeeWee/rn-typescript-example/tree/ts-loader-bug to display this new issue. If you run it out of the box, with Note that you'll need to run the webstorm configuration with --no-cache to provoke it reliably. |
I don't really use babel or synthetic imports so I'm not sure what needs to be done here. When Maybe @ds300 can chime in? |
Yes that makes perfect sense! Because babel-jest ( at least with the react native preset ) creates synthetic default exports that typescript can grab. It seems like the problem here would be that if the ts files are passed to babel-jest, the sourcemaps are not included. I have set I would be willing to do a PR explaining a more detailed react-native setup guide. (e.g. someone should really mention it pipes it through babel-jest if you use |
@GeeWee that worked! A PR with the explanation would be very welcome :) |
Wonderful! I'll definitely get a PR up and rolling, though I'll want to make sure the same setup works in VSCode as well :) |
@kulshekhar - this setup also works in VSCode. At least almost. |
@GeeWee It might be best to add instructions for Webstorm/IDEA (since we have that working) and open a new issue for VS Code. |
@kulshekhar This workaround does work, however it is an issue since now the test code after compilation does not match the actual code after compilation. For example: import * as pathToRegexp from 'path-to-regexp'; The library above requires When running in test I get an error since the imported module This creates an inconsistent behaviour |
@shlomiassaf are you referring to this workaround? |
Actually I used the other one but it's the same. |
@shlomiassaf those two aren't the same. If there seems to be a problem, can you create & share a minimal repo specific to your case? |
I have created #212 for the VSCode issue. |
https://github.com/shlomiassaf/ts-jest-issue-209
import * as pathToRegexp from 'path-to-regexp';
console.log(`Type of module alias import of "path-to-regexp" is ${typeof pathToRegexp}`); This should show that pathToRegexp is a function Then import * as pathToRegexp from 'path-to-regexp';
describe('TEST', () => {
it('module alias import of "path-to-regexp" should be a function', () => {
// if this fails it means that pathToRegexp is an object with a "default" property that is the expected function
expect(typeof pathToRegexp).toEqual('function');
});
}); It will fail since pathToRegexp is now an object with a default property referencing the function. Note that both You can remove the .babelrc file, it will still fail the test. |
@shlomiassaf I'm slightly confused here. How is this relevant to the proposed solution (which sets |
@kulshekhar If you look at the code you will see that for the same code compiled with TS, ts-jest emits a different output.
When using this statement: import * as pathToRegexp from 'path-to-regexp'; In TS compilation without It's not deterministic, different outcome for the same TS compilation process |
@shlomiassaf that's because when This is also unrelated to this issue. If you think there needs to be a discussion on this here, it might be better to open a new issue so that we can focus better. |
@kulshekhar I'll open an issue, just to understand, why would you need babel for that? you can use TS compiler to emit ES5 code. |
When running a react native configuration, it is impossible for me to get any breakpoints to register in Webstorm.
Debugger statements work but do not break at the correct line.
I have a suspicion that the sourcemaps are to blame. This is an example of it breaking before the debugger statement:
However when I remove the typescript interface it breaks like this:
My thoughts are, that it is using an es6 sourcemap, and not the typescript sourcemaps.
My tsconfig is set to enable inline sourcemaps, and looks like this:
and jest config looks like this:
I do not know if this is a webstorm or jest regression, or whether the react native build setup has anything to do with it.
I expect to be able to set breakpoints, and that the debugger statements stop at the correct place.
This is a minimal repo that reproduces the issue. Simply go to the some-test.test.tsx, and in webstorm left click on the test and click debug.
https://github.com/GeeWee/rn-typescript-example/tree/ts-loader-bug
I'm not sure how to set up any test cases for this particular bug.
The text was updated successfully, but these errors were encountered: