Reputation: 7490
I have lot of my JS
files in my projects. Some of them are external libraries. I want to know what JS
code is executing for current user interaction. I have set up break point in chrome as describe here. But there are already lots of JS
files and lots are added by Visual Studio
of his own. So it becomes difficult for me to get to exact code. So in this case, I need something that will enable me to debug only xyz.js
file.
Upvotes: 13
Views: 4387
Reputation: 8709
Based on adamtickner's explanation here is a detailed description. Let's assume the file you want to debug is "src/app.js"
In Chrome open the debugger using F12 and then click settings (gear icon ⚙ , top right window corner). Select the "Ignore List" menu item.
So far so easy. The tricky part is to add the right regular expression. We need an expression saying "everything, except...". This can be done by a technique called "negative look-arounds"
Our positive expression would be:
src\/app\.js
We just escaped the slash and the dot as these are reserved regex characters.
Now, using negative look-arounds, our expression should look like this:
^((?!src\/app\.js).)*$
This expression will find anything which does NOT contain our file path. You can test it with regex101. Add this pattern to your Ignore List and you are done! Chrome will maybe show a misleading message when you debug in this file like "This script is on the debugger's ignore list" - just ignore this message, you can still debug into the ignored files.
Upvotes: 5
Reputation: 140
Open up settings in chrome dev tools, click on "Blackboxing" or possibly "Manage framework blackboxing" and set up file names or regex patterns. Any scripts matching this will not be debugged when you are stepping through your own code and reach a point at which you would enter that script.
Upvotes: 9