Debug IML in VS Code

There're options to debug your IML code locally on your computer.

1. Automated testing with Mocha

The first option is to do automated testing with Mocha. The process and examples can be found in the link below.

pageIML tests

2. Debug code in Visual Studio Code

  1. Copy your IML code.

  2. Go to VSC -> File -> New Text File (Shortcut: ⌘ + N - on MacOS, Ctrl + N - Windows/Linux).

  3. Paste your IML function. To execute a code you will need 3 more things:

    1. 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).

    2. 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) .

    3. Remove all IML functions called inside. All debug() and iml.function() should be removed or replaced by similar JavaScript functions.

  4. Put breakpoints on your code (it's red dots on the left side of line numbers).

  5. Upper menu Run -> Start Debugging -> set Node.js as debug environment

  6. 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

  7. 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).

Last updated