Debug IML in VS Code
Last updated
Last updated
There're options to debug your IML code locally on your computer.
The first option is to do automated testing with Mocha. The process and examples can be found in the link below.
Copy your IML code.
Go to VSC -> File -> New Text File (Shortcut: ⌘ + N - on MacOS, Ctrl + N - Windows/Linux).
Paste your IML function. To execute a code you will need 3 more things:
Input example.
You can either type it manually or use debug()
inside the IML function on Make and copy input from the developer console of your browser (more about debug()
here).
Call function.
Since we are testing the function locally, we cannot run a scenario to execute it. To imitate scenario execution we need to call a function by its name and send the input, that we specified before, inside it. Example: myFunction(input)
.
Remove all IML functions called inside.
All debug()
and iml.function()
should be removed or replaced by similar JavaScript functions.
Put breakpoints on your code (it's red dots on the left side of line numbers).
Upper menu Run -> Start Debugging -> set Node.js as debug environment
Enjoy! On the left side of VSC, you will see variables that are being processed at the moment. Go through the code step by step and find your bug
If you're interested to explore VSC debug tool check their docs here.
In this example, Transport type
shouldn't be sent in the request and Year
should be sent as a number (not text).