This example can be used to test functions in Google Apps Script code.
It uses the Node.js VM module to create an ad hoc script,
which consists of the function's code to be tested as well as an invocation of the function to be evaluated.
The result of the script is returned by execute
and can be asserted afterwards.
If the function uses global objects (e.g. DriveApp
, SpreadsheetApp
or GmailApp
), stub implementations can be provided as context for the script execution.