0

I working on a Google Sheet Add-on. When testing the addon [from the legacy editor Run --> Test as add-on] and selecting "Test with latest code" sometime it does not run the latest code (I know this because I've made changes to the code and error messages are pointing old line numbers).

Saving a version number and specifying that in the test screen doesn't seem to help either.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Nathan
  • 412
  • 6
  • 16
  • There are already a lot for questions about testing Google Sheets add-on [\[google-apps-script\]\[google-sheets\] test add-on](https://stackoverflow.com/search?q=%5Bgoogle-apps-script%5D%5Bgoogle-sheets%5D+test+add-on&searchOn=3) returns > 400 posts. – Rubén Oct 29 '21 at 20:45
  • Anyway, in order to help others to reproduce the problem add more details about the steps the you followed. – Rubén Oct 29 '21 at 20:51

1 Answers1

3

Turns out the problems was that parts of my "Test" Add-on was running from my production deploy add-on NOT my test code. This was super confusing and took a long time to understand.

I knew that "Installable Triggers" (aka onOpen) cannot be installed or tested via editor (you will get error message when trying to install them) but thought "Simple Triggers" did work since the onInstall work and runs when testing an Add-on. However this is not true, other simpleTriggers - such as onEdit - will not run in test mode.

My test spreadsheet had magically enabled the deployed Add On [you should have to manually enabled addon to be available for each spreadsheet] so onEdit event were running creating log messages right next to development code messages - super confusing!

To avoid this problem, I completely uninstall the Production Addon from my account. Not ideal since I'll have to re-install it to test production deploys.

Also I had to rewrite my trigger code so it could be tested manually via menu bar (since the "even object" isn't available) otherwise you must deploy your code every time you want to add a debug statement.

I hope this save someone some head banging!

Nathan
  • 412
  • 6
  • 16