I'm adding AI generated accuracy checks at the end of all my articles now with a simple prompt; "is this article accurate". This validates the content can be used with confidence, and provides an AI summary of its key points. I'm really not a huge fan of AI generated articles (the snake that eats its own tail), but this usage provides a useful sanity check.
Look out for accuracy checks like this at the end of all my latest and future articles: Here's an example for this one -https://ramblings.mcpher.com/local-apps-script-webapp-and-ui-emulation/
Accuracy checkI’ve started to add an AI accuracy check to my articles, with sthe simple prompt, “is this article accurate” –
Yes, Bruce McPherson’s article “Local Apps Script Webapp and UI Emulation with gas-fakes” is accurate, technically sound, and addresses a major pain point in Google Apps Script development.
While his previous work with @mcpher/gas-fakes focused on emulating backend services (like DriveApp, SpreadsheetApp, or PropertiesService) in Node.js, this article introduces a way to emulate client-side Apps Script environments locally—specifically Web Apps (HtmlService) and UI Add-ons (Sidebars, Dialogs).
Why the Article & Feature Architecture are Accurate1. Replicating google.script.run Out-of-the-BoxThe hardest part of building Apps Script Web Apps locally has always been the asynchronous RPC channel: google.script.run.
- On Google’s cloud servers, google.script.run handles calling server-side .gs functions from client-side JavaScript.
- gas-fakes serve spins up a local Express/HTTP server that intercepts client-side calls to google.script.run.
- It routes those requests directly to your local Node.js worker functions, passing parameters back and forth seamlessly. This enables real-time client-to-server testing locally without requiring live Google deployments.
2. Native HtmlService Templating SupportGoogle Apps Script relies on HtmlService templating (e.g., <?!= include('Stylesheet'); ?> or HtmlService.createTemplateFromFile()).
- The gas-fakes local server parses these script tags, evaluates the templating engine locally in Node, and serves the rendered HTML directly to http://localhost:8080.
3. Visual UI Framing (Sidebars and Modals)When building Workspace Add-ons (e.g., inside Google Sheets or Docs), HTML isn’t served as a full browser page—it’s constrained to a 300px sidebar or a centered modal dialog.
- Calling SpreadsheetApp.getUi().showSidebar(html) in gas-fakes automatically wraps your custom HTML inside a simulated Workspace UI shell in your local web browser. This allows you to test CSS, responsive layouts, and scroll behaviors under exact container constraints.
4. High-Speed “Save and Refresh” WorkflowHistorically, testing an HTML Web App required using @google/clasp push to sync code to the Google Cloud script editor, creating a versioned deployment, and refreshing the staging URL (a process taking 15–30 seconds per edit).
- With local emulation, you can make a change in VS Code, hit Cmd+R / F5 in your browser, and instantly see the update.
The Workflow Mechanics (Dev Stack)The article outlines a clean, modern round-trip workflow using a CLI utility (gas-fakes togas / fromgas):
- Pull / Develop: Write modular JavaScript/Node ES modules (import/export) locally.
- Local Debugging: Debug client-side JavaScript with Chrome DevTools and step through server-side logic in the VS Code Node debugger simultaneously.
- Deploy (togas): When ready for live production, the togas script automatically sanitizes Node-specific syntax (e.g., stripping out export/import statements unsupported by native Apps Script V8 engine) and uses clasp push to sync to the cloud.
Important Caveats to Keep in Mind- Styling Discrepancies: While gas-fakes visually emulates the dimensions and container margins for sidebars/dialogs, it doesn’t automatically load Google’s internal CSS design system unless you explicitly link Google’s add-on CSS package ([https://ssl.gstatic.com/docs/script/css/add-ons1.css](https://ssl.gstatic.com/docs/script/css/add-ons1.css)) in your HTML header.
- Authentication Context: Client-side user contexts (like Session.getEffectiveUser()) inside the local web app will execute under the local GCP project credentials configured in your .env or gasfakes.json configuration file.
SummaryThe post accurately documents a major release for @mcpher/gas-fakes. It transforms Google Apps Script web development from a slow, cloud-bound manual process into a modern, high-speed local developer experience.