0

I tried to follow rigorously this basic "QUnit for Google Apps Script" tutorial: https://blog.ohheybrian.com/2019/11/unit-testing-gas-part-1-qunit-setup/

But when I connect to the deployed web-app, I get this error "Error: An error has occurred on the server. We apologize for this and invite you to try again later. (line 0, "undefined" file)".

QUnit for GAS web-app error

So I tried to make a basic web-app with just this code to make sure a simple web-app works fine:

function doGet(e) {
  var params = JSON.stringify(e);
  return HtmlService.createHtmlOutput(params);
}

And it works.

But when I just had this line "QUnit.helpers(this);" and the QUnit library, I get the error message mentioned before.

Any idea of what is wrong?

I'm really surprised that Google Developers still not provide a builtin testing framework for GAS and related tutorials. It could encourages to make clean code.

Best regards, Florent

TheMaster
  • 45,448
  • 6
  • 62
  • 85
  • The library hasn't been updated for 4-7 years. Lots of things might be broke. – TheMaster Feb 26 '20 at 07:47
  • Have you authorized the script? You can do that just by calling a null function to give it a chance to set all the scopes properly – Cooper Feb 26 '20 at 08:11
  • Thank you @TheMaster ! Do you have alternative tools to recommend for GAS unit testing automation? – Florent Feb 26 '20 at 16:21
  • Thank you @Cooper ! Yes I did it. – Florent Feb 26 '20 at 16:25
  • I'm sorry. I don't. – TheMaster Feb 26 '20 at 16:26
  • 1
    Hi, just for people meeting the same issue, the best solution I found is GAST (https://github.com/huan/gast). I also suggested to the Google Team the development of a builtin unit testing tool for Google Apps Scripts Editor. Here is the link to participate to the discuss and vote : https://issuetracker.google.com/issues/150274442 – Florent Feb 27 '20 at 19:14
  • Kindly add it as a answer in the answer box below. – TheMaster Feb 29 '20 at 12:27
  • Does this answer your question? [how to unit test google apps scripts?](https://stackoverflow.com/questions/15682346/how-to-unit-test-google-apps-scripts) – TheMaster Feb 29 '20 at 20:20
  • 1
    Personally I've not had any problem running the old QUnit lib for GAS, but do check out [QUnitGS2](qunitgs2.com) - a new Apps Script library using the latest version of QUnit (v2.10.1) and V8. – Andrew Roberts Aug 02 '20 at 08:18

0 Answers0