Debug Test Autoamtion Code in VS Code
Learn how to debug a BlinqIO scenario using Visual Studio Code (VS Code).
Prerequisites
Make sure you have the following ready before debugging:
- An implemented scenario using GenerateAll, GenerateStep, Recorder, or API App.
- Any pending AI Oversight suggestions have been accepted for the code you want to debug.
Add a Unique Tag to the Scenario
Open the scenario you want to debug, click Edit, and add a unique tag like
debug
.
Generate and Copy the Run Command
Generate a command-line command to run the scenario based on the unique tag.
Go to the Reports page.
Click How to run scenarios to open the Run Instructions.
Choose the tag you added from the dropdown menu.
Copy the command from the Run Instructions.
Example command:
npx cross-env BLINQ_ENV=environments/prod.json TOKEN=56c0dsdda3fb1b7b8c86af21f021c3c5 BVT_FORMATTER="ANALYSIS" cucumber-js --format bvt --tags "@test"
Open the Project in VS Code and Start Debugging
Now you’re ready to debug the test automation code in VS Code:
On the Project page, click the three-dot menu and select Open in VS Code. This will sync the project to your local system and open it in VS Code.
Open the automation code file (
.mjs
) underfeatures/step_definitions
in VS Code and add a breakpoint in the function you want to debug.Open the terminal in VS Code by selecting View > Terminal or by pressing Ctrl+`.
Switch to the JavaScript Debug Terminal by selecting Create JavaScript Debug Terminal from the terminal dropdown.
Paste and run the command you generated earlier in the JavaScript Debug Terminal. The test will start running, and the debugger will stop at any breakpoints you’ve set.
For more details on debugging in VS Code, check out the VS Code Debugging Documentation.