API test console logging
We are happy to share that mabl supports console logging in API test scripts! Debugging complex API scripts is now easier than ever. Console logging works with all of your API test scripts, including the pre-script, script, and flow-level script.


Console log functions added to the pre-request script of an API step
Viewing the output
The output of your console log statements is visible in the API test editor and the API Test Output page for cloud runs, as well as the output of local runs via the CLI.
In the API test editor
When you click the send button, the console logs will be available as a tab in the results panel:


For cloud runs
You can find console logs for each step of your API test on the Test Output page:


In the mabl CLI
Console logs are included in the output from API tests executed with the mabl CLI:
API test with console log
→
┌
│ 'Reticulating splines before API request.'
│ 'Reticulating complete:', { splineCount: 42, averageReticulation
│ 9m: 0.98 }
└
GET https://localhost:8080/test/splines OK, 1kB, 243ms]
┌
│ 'Resetting splines after request.'
└
✓ Status equals 200
┌─────────────────────────┬────────────────────┬───────────────────┐
│ │ executed │ failed │
├─────────────────────────┼────────────────────┼───────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ requests │ 1 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ test-scripts │ 1 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ prerequest-scripts │ 1 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ assertions │ 1 │ 0 │
├─────────────────────────┴────────────────────┴───────────────────┤
│ total run duration: 307ms │
├──────────────────────────────────────────────────────────────────┤
│ total data received: 102B (approx) │
├──────────────────────────────────────────────────────────────────┤
│ average response time: 243ms [min: 243ms, max: 243ms, s.d.: 0µs] │
└──────────────────────────────────────────────────────────────────┘
10:34:07 AM - Test Passed
You can start using API Test console logs in the latest version of the desktop app (version 1.16.14) and web application.
For more information on using JavaScript in your API tests, check out the guide.