1

I'm trying to set up my app script project using clasp and test it locally using gas-local, I have reached the step of testing but I got this error ReferenceError: SpreadsheetApp is not defined.

gas.js

 //require gas-local itself
 var gas = require('gas-local');
 //require your downloaded google apps script library from src subfolder  
 var glib = gas.require('./src');

where src is my google app script project folder, however when I node gas I got the ReferenceError: SpreadsheetApp is not defined

The idea from using gas-local is that I want to know my GAS cloudProject ID programatically, so I thought I would trigger any method locally and get the project-id from the error message that will be thrown.

I would appreciate anyone writes a step by step guide with screenshots if possible showing how to accomplish this process.

ilya
  • 611
  • 6
  • 17
  • 1
    You need to write your mock simulating `SpreadsheetApp` with all the functions inside. See readme of gas-local for the custom mockup of MailApp.getRemaingQuota(). – TheMaster Apr 12 '19 at 08:57
  • @TheMaster so it will not be like the real SpreadsheetApp? I need it to be like the real one so that I can get GAS cloudProject ID programmatically. – ilya Apr 13 '19 at 10:32
  • That's a completely different question and better asked in a different post. Why do you want to retrieve the project-id programmatically? – TheMaster Apr 13 '19 at 11:33
  • @TheMaster to enable the required services programmatically like "gcloud services enable drive.googleapis.com" so that I can test my methods. – ilya Apr 13 '19 at 11:46
  • https://stackoverflow.com/questions/54757388/ – TheMaster Apr 13 '19 at 13:19
  • @TheMaster thanks for helping, but this answers how to get a standard GCP project; I want the default project that is created for Apps Script projects- which it doesn't appear in that list unfortunately – ilya Apr 13 '19 at 14:02

0 Answers0