logo

NJP

JS Code Coverage Debug

Import · May 13, 2022 · article

Dear coders, developers,

Hope everyone's doing good ...

This feature exists since Paris. Can you believe it?

A gem which was truly hidden.

Read further to truly understand what I mean by saying it as a "gem".

A BIG time saver!

Many experts might know it, but tools like this, really makes the platform so very competent and such a breather for both learners and developers.

"JS Code Coverage Debug"

  • No need to set breakpoints OR
  • Even review on screen debug messages.

sys_js_code_coverage.LIST

This place or records listed here gets you an insight of which lines of code did run/execute during a user session.

Following are the details captured:

  • The user session that called the script.
  • The script record the system called identified by table, sys_id, and script field.
  • The script record the system called identified by type and name.
  • The transaction that called the script.
  • The start time of the transaction.
  • The contents of the script field highlighted to indicate which lines the system ran.

[GREEN - executed, RED - skipped, GREY - non-executable.]

Activate the plugin - "com.glide.js.coverage" and save your time, if you are yet to do it. Hurry up!!!

Navigation - JS Code Coverage Debug > Enable Coverage.

Check out the following screenshot when an incident is inserted.

image

This clear distinction between the lines of code that did execute and the ones that did not, I know many developers feel relaxed by now. Keep using and exploring the platform.

Do post in comments, if you knew this already and share your experience.

Best of luck with your debugging!

Cheers,

Anish Reghu

View original source

https://www.servicenow.com/community/developer-articles/js-code-coverage-debug/ta-p/2306139