Use the debugger tool in Code Repositories to examine the behavior of your unit test while it runs. Set breakpoints to pause the execution of the unit test in order to examine variables, and understand functions and libraries.
To use the debugger, you need to set breakpoints. These breakpoints indicate the specific points where the debugger should pause the code execution, enabling you to interact with variables.
Set a breakpoint by selecting the faded red dot in the margins of each line of code. The debugger suspends the execution before the marked line runs. You can set multiple breakpoints across several files, if needed.
After adding breakpoints in your code, select Run test, located next to the unit test in the code editor. The debugger panel will open and pause on the first breakpoint it encounters. The left bar of the debugger allows you to navigate the code, remove breakpoints, and finish/stop the debugging session.
As you navigate in the code, the editor highlights the line of code to be executed next. Use the following buttons to advance the debugger:
While the debugger is running, you can examine the variables and data at the exact point of code execution.
Frames represent the functions in which the debugger is active or breakpoints exist. Each frame indicates the name of the function followed by the name of the file and the line number in which the function is written.
Select a frame to examine the variables within that frame and run console commands against it.
The variables section displays the values stored in both local and global variables while the transform is executed.
The console allows you to interact with your data using Javascript console commands while running the debugger. There are two commonly used patterns in the console:
Note that the console operates within the context of the selected frame. Attempting to execute commands on variables local to a different frame will lead to an error.