-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
feature/add-first-class-debugging-support-for-tests #1360
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact [email protected] if you have any questions. |
var scriptArgs = [require.resolve('../scripts/' + script)].concat(args); | ||
var debugFlag = getDebugFlag(args); | ||
if (debugFlag) { | ||
scriptArgs.unshift(debugFlag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note, running node --debug-brk ./node_modules/.bin/react-scripts test --debug-brk
will biff on conflicting port access to 5858, if this wasn't clear already. I did not handle this case, but it may be worth discussion?
* Greetings! If you are here attempting to start a debugging session, please | ||
* ensure that your debugger of choice is configured to enable source maps, | ||
* otherwise your code may appear mangled by babel! | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 greet the debugging user with some 🌶 🔥 tips
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
if (!isRunInBand) { | ||
argv.push('--runInBand') | ||
} | ||
argv.splice(argv.indexOf(debugFlag), 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any of the node debug flags are not valid input to jest
. something counter convention i did in this PR was allow a debug flag (like --debug-brk
) to enter via argv, where previously all of the other args were jest
specific. IMHO, this is OK. the filtering may be cleaner towards the top-of-the-file
i'm a little puzzled w/ the CI error. it fails on being unable to locate a file, but only on some node versions. maybe a caching thing? can someone weigh in or re- kick it off? |
@cdaringe CI fails becasue this require at
utils dir is not available after |
@@ -7,3 +7,4 @@ template/src/__tests__/__snapshots__/ | |||
lerna-debug.log | |||
npm-debug.log | |||
/.changelog | |||
.vscode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,5 +1,6 @@ | |||
#!/usr/bin/env node | |||
var spawn = require('cross-spawn'); | |||
var getDebugFlag = require('../utils/getDebugFlag'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this to work after the eject, you'll probably have to add the right path here.
c976b56
to
14d53fb
Compare
thanks @tuchk4, @EnoahNetzach. i dropped the editor ignore commit, rebased w/ patches to restore the build. should be g2g now, post review :) |
FYI, to reviewers, this also only accepts one flag as written. that is |
Tagging with a milestone because we need to review this. |
i'm not entirely in love with the implementation, especially now that |
Would love to see this land or help in making it happen. Especially as Webstorm/IntelliJ integrated testing would then work with create-react-app (related issue). |
I won't have time to review this until first week of April. |
@Timer any updates on this? |
Just added it to my list of soonish TODOs, @lifeiscontent. Thanks for the reminder. ❤️ |
@Timer you rock! 👍 |
Considering that the legacy protocol is dead, I'm not sure if we should implement it ( On that note, I'd like to see support for strictly Also, we should make sure it supports the port syntax @cdaringe do you happen to have any free time to bring this PR up to date? |
totally. in agreement.
yep. agreed.
if you can find a way around it, that'd be great! i'm swamped for a few weeks--i wont be getting to it anytime soon. :( |
So looking fwd to this, it will also enable Jetbrains to debug JSX: |
@cdaringe not a problem, thanks so much for letting me know! |
babelrc: false | ||
}); | ||
const babelJestDebugConfig = require('./babelJestDebugConfig'); | ||
module.exports = babelJest.createTransformer(babelJestDebugConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was probably supposed to be Default
v Debug
?
|
||
const babelTransform = isEjecting | ||
? '<rootDir>/node_modules/babel-jest' | ||
: resolve('config/jest/babelTransform' + (isDebug ? 'Debug' : '') + '.js') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Timer, 👀, this is where/why there were two babelTransform files. we are passing the babel config as a file path, therefore, to enable sourceMaps, i added a different file. if there's another way to get those babel settings passed to jest, we could pursue that. we could also set something in the ENV to drop it down to one transform file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I hadn't reviewed deep enough to have this understanding.
Thanks for explaining!
I'll snoop around and see what our best option(s) are. 😄
would somebody pleeaaase merge this! I am pulling my hairs on debugging for a week now :'( |
@thg303 you should have some hairs left before webstorms 2017.2 release |
Sorry for the delay @thg303. |
moving to #2041 |
The solution does not work for me, I can't figure out how to debug jest. |
It's super old on the react-scripts time scale, I wouldn't expect it to |
For those who are also stuck, it looks like you can downgrade to node 7.10 to debug: |
problem statement
react-scripts
does not offer ready-to-roll jest debugging.solution
--debug-brk
anddebug
are working flags passed tonpm test
. that isnpm test -- --debug-brk
works. i think this is a nice entry point into the system.closes #594