Unit Testing running on the console

246 views
Skip to first unread message

David Leal

unread,
Sep 12, 2021, 6:51:46 PM9/12/21
to Google Apps Script Community
Hi,

I was trying to find some unit testing framework for the custom function I created using Apps Script. I was able to test it using QUnitGS2, it is a great library, but it runs on Google Server, so it takes time for getting the result and you need to reload the URL of the web app deployed every time.

I am wondering if there is a simple unit testing library/framework that runs locally, so you can have more control of the execution and provide the results in the console output, instead of deploying the web app and then going to deployed URL. I made some reach on the internet, but all I found were libraries running on servers. 

Thanks,

David

Andrew Roberts

unread,
Sep 12, 2021, 6:57:00 PM9/12/21
to google-apps-sc...@googlegroups.com
Wouldn't all the Apps Script service calls have to be stubbed out or simulated to run Apps Script locally? And if that was the case you could use the original native QUnit JS library. You may find something helpful if you look at what people have done for editing Apps Script offline with tools like Clasp. 

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/7e33939c-ccd9-43fe-8e41-c420683c7d49n%40googlegroups.com.

David Leal

unread,
Sep 13, 2021, 2:50:39 AM9/13/21
to Google Apps Script Community
Thanks, Andrew, I am using Google Apps Script, per Qunit documentation it runs in node.js or in a browser. I created a simple custom function that I would like to test, It would not need a browser for getting the results, nor running the tests in a Google Server. I was looking for something that generates the output directly to the Google Apps Script console.

David Leal

unread,
Sep 13, 2021, 2:50:45 AM9/13/21
to Google Apps Script Community
Thanks, Andrew, Qunitjs runs in node.js or browser,  I am using Google Apps Script. Testing a custom function should not require a web browser or a server for doing such kinds of unit tests.

On Sunday, September 12, 2021 at 6:57:00 PM UTC-4 and...@roberts.net wrote:

Goran Kukurin

unread,
Sep 13, 2021, 9:18:54 AM9/13/21
to Google Apps Script Community
I use Typescript, TS mockito + Chai. A project gets transpiled to javascript code and packed with webpack. 
I mock all required AppsScript classes and run the unit tests locally. It works fine.

What I did not found yet is a testing framework that would run tests in the AppsScript environment, but unit tests like described save me a lot of troubles already.

dimud...@gmail.com

unread,
Sep 13, 2021, 11:21:51 AM9/13/21
to Google Apps Script Community
"I was looking for something that generates the output directly to the Google Apps Script console."

Adam Morris' UnitTesting library is perfect for this. I use it regularly to test scripts from the GAS console.

Check it out:
https://github.com/classroomtechtools/modularLibraries.gs/tree/master/UnitTesting

David Leal

unread,
Sep 18, 2021, 2:39:00 PM9/18/21
to Google Apps Script Community
Thanks, both of you, I finally found this library, that is well documented and easy to understand:

Dimud, I checked your suggestion: Adam Morris' UnitTesting library, but it is more complex to understand and too verbose. I created a branch with some minor improvements.

Regards,

David

Reply all
Reply to author
Forward
0 new messages