Scheduled workflows that read a Google Sheet and send Gmail/Calendar are easy to build and painful to trust: they run on a timer, they touch real accounts, and a bad run emails real people. Here’s the setup I landed on after shipping a few of these.
1. Swap Google nodes for a mock server in tests.
In CI I point the Google Sheets / Gmail / Calendar nodes at a tiny HTTP mock that keeps state in memory (rows, sent emails, calendar busy slots). The workflow logic runs for real; only the Google calls are faked. That means I can assert “lead X got exactly one day-3 email” without a single real send.
2. Seed demo data with dates relative to today.
A fixed fixture breaks the moment “day 7” drifts out of range. My seeder writes rows dated TODAY()-1, TODAY()-3, etc. So every scheduled run always has something to do, in tests and in a live demo.
3. Two gotchas that cost me real time:
Calendar primary in ID mode: the Google Calendar node rejects primary as a calendar ID - it wants the account’s email address. A live run caught it; now a regression test covers it.
Webhook registers asynchronously (~1 s) after activation. Tests that fire the webhook immediately after activating fail at random. The fix is to wait/poll for the webhook to be live before the first call.
4. Make “stop” conditions explicit.
For any follow-up sequence, the status check that stops the sequence (Replied / Booked / Unsubscribed) is the part that protects your sender reputation. I test the stop path more than the happy path.
I fake the clock. Trusting the cron hides the bugs that only show up on day 7, at month end, or right after a weekend.
The setup that works for me: the Schedule Trigger only starts a thin wrapper, and that wrapper passes a single now value into the real logic (an Execute Workflow sub-workflow). In production now is {{ $json.timestamp }} from the Schedule Trigger. In tests I call the same sub-workflow with whatever date I want, like the day before a month rollover. Every date check inside reads that input, e.g. DateTime.fromISO($('When Executed by Another Workflow').first().json.now), never $now, so a test run behaves exactly like that day’s scheduled run would.
One more gotcha for your list is timezone. The cron fires in the workflow’s timezone setting, which falls back to the instance’s GENERIC_TIMEZONE, and a self-hosted instance with neither set runs on America/New_York. A “9am” email can quietly go out at 6am for someone on the West Coast and nothing errors. I set the timezone explicitly in Workflow settings and keep one test with now just before midnight to catch off-by-one-day comparisons.
Thanks, both points are spot on, and the timezone one turned out to be a real bug in my templates, not just a testing nit. None of them set the workflow timezone, so on a self-hosted instance without GENERIC_TIMEZONE the Schedule Trigger would fall back to America/New_York and fire at the wrong local time, with no error. I’ve now set the timezone explicitly in Workflow settings (matching the Config node) on every scheduled workflow, and added a check that fails the build if a workflow with a Schedule Trigger doesn’t have one.
On the clock: right now I move the data instead of the clock (the seeder writes rows dated relative to today). That covers day-N logic but can’t simulate a month-end or a Monday after a weekend. Passing a single now through an Execute Workflow input solves exactly that while keeping prod and tests on the same path, so I’m stealing it, along with the just-before-midnight test.
Do you also assert on the number of sends per run, or only on the content? I’d expect the near-midnight cases to be where a sequence could double-fire.
For your mock-server setup, I’d give the follow-up logic an explicit asOf input. Set it once from $now.toISO() at the production entry point; in CI, pass a fixed ISO timestamp and seed rows relative to that same timestamp. Your live-demo seeder can keep using today. This makes the business-date tests repeatable.
For the weekday 09:00 / D1–D3–D7–D14 sequence in your other post, I’d start with these cases:
Fixture
What to assert
Lead created Friday 9 Oct; run Monday 12 Oct
With calendar-day offsets, D1 fell on Saturday and D3 falls on Monday. Define the catch-up policy: earliest unsent step, latest due step, or another agreed rule. Assert the exact step and total email count.
Replay that Monday run after its successful state update
Zero additional emails for the already-recorded step.
Same due lead, once eligible and once for each stop status
The eligible control sends the expected step; Replied / Viewing booked / Unsubscribed each sends zero.
Europe/Paris: 24 Oct 2026 at 09:00 → 25 Oct at 09:00
One calendar day spans 25 elapsed hours. Assert the intended calendar-day or elapsed-time rule in the selection logic; exercise the weekday scheduler separately.
For that last fixture, use your actual business timezone; Paris is a useful DST example. n8n’s date documentation covers Luxon and workflow-timezone handling.
Could you share the mock stub and the Code node that selects due leads? I can adapt these cases into a small acceptance table against your existing test setup.
Thank you, this was worth a lot more than a testing tip. Your point about asserting the calendar-day vs elapsed-time rule exposed a real bug in my templates:
The due check compared elapsed time to the gap (now.diff(lastContact, 'days') < gap), and lastContact is the previous run’s own timestamp. If today’s run reached the Code node a few hundred ms “earlier in the second” than the last one, 1.9999 days < 2 and the follow-up slipped to the next run (or past the weekend). Same effect for an enquiry at 2pm: its “day 1” email waited until the day after.
Fix: compare calendar days in the workflow timezone, today.diff(last.setZone(now.zone).startOf('day'), 'days'). Same pattern fixed in the quote follow-ups and the review reminder of my contractor templates.
Your four cases are now automated tests that run the exact jsCode from the exported workflow JSON with Luxon’s Settings.now frozen and Settings.defaultZone set to the workflow timezone, in EN and FR:
Friday enquiry, Monday run: the catch-up policy is “earliest unsent step, one email per run”, and the next gap counts from the actual send (asserts the email count, the step and the next due date).
Replaying Monday after the state update: zero emails.
Due lead as a control, then zero for every stop status.
Europe/Paris 24 → 25 Oct (25 h) and 28 → 29 Mar (23 h): both count as one day.
Your four already passed on the old code; the cases they led me to add (run-time jitter, afternoon enquiry) failed, 12 failures across EN and FR, and everything passes now. The separate scheduled smoke test for firing time is not built yet, it’s on my list.
The selection Code node is in the free follow-up template, so you can see the whole thing there. Here is the core of the due check:
const now = DateTime.now();
const today = now.startOf('day');
// ...per lead:
const last = parseDate(row['Last Contact At']) || parseDate(row['Last Enquiry At']);
if (today.diff(last.setZone(now.zone).startOf('day'), 'days').days < gaps[step]) continue;
Thanks, Chris — the run-time jitter and afternoon-enquiry cases are the regression pair to keep next to that fix. Your report gives them a useful red/green history across both languages. “Earliest unsent step, one email per run, next gap from the actual send” also makes the weekend catch-up contract very clear.
For the remaining scheduled smoke, I’d reuse your stateful mock:
Publish a test copy with the same Schedule Trigger and explicit workflow timezone, with the Google boundaries routed to the mock.
Record the trigger’s timestamp, the mock’s receipt time and the workflow ID at the entry point.
Have a check outside that workflow look for one scheduled execution on each expected local weekday, within an agreed window such as 09:00–09:05. That check can also report a missing run.
A short-interval schedule gives you a quick activation check; keeping the actual weekday/09:00 rule exercises the release’s real firing configuration. The frozen-clock suite can keep covering the calendar cases on every build.
Is your release workload mainly the EN/FR kits, or do you also maintain customized versions for clients? That would help pick the most useful next check.
Mainly the two packaged kits, real estate and home services, each generated in EN and FR from a single source, so a fix lands in both languages at once. No customized client versions so far: buyers get the same JSON and adapt the Config node.
Your smoke-test design is noted: a test copy on the real weekday 09:00 rule, plus an outside check for one execution per expected weekday within a window, fits the stateful mock I already have.
Thanks, Chris — that makes the next release check quite focused: two kits × two languages, using the generated JSON that buyers download.
I’d run the timing/stop/replay assertions with the shipped Config defaults, then with one supported non-default Config profile. For each run, check the exact lead IDs and follow-up steps; for the EN/FR pair, compare those business decisions while checking the localized message text separately. That exercises the customization boundary your buyers actually use.
The shared generator and your existing export-based tests are a good foundation for that matrix. If you share the mock stub and one dummy Config profile, I’d be happy to contribute one concrete config-variation fixture to your existing suite.
Thanks, that matches the current setup: the frozen-clock suite runs the jsCode from the exported JSON in EN and FR, with the shipped Config and with overrides (holidays, per-run cap, summary off), and asserts lead IDs and steps. The same fixtures run against both languages, so a divergence in business decisions fails the build; the message texts are checked separately.
I’ll keep the mock in-house, it’s tied to my harness and not worth extracting.
One thing this thread pushed me to ship today: before sending anything, the follow-up now searches Gmail for replies, so a lead who answered, or wrote STOP, leaves the sequence on their own, and the agent gets one summary of who to call back. Thanks again, this thread made the templates better.
Thanks, Chris — the export-based EN/FR checks and Config overrides sound well covered. Reply/STOP detection before the next send, plus a single callback summary, is a useful addition for the people running the kit.
I’m glad the calendar-day discussion helped uncover the jitter and afternoon-enquiry cases. Thanks for coming back with the concrete results, and best of luck with the release.
mocking time-based triggers and third-party rate limits is critical when building production automations that run on fixed schedules.
for our distribution flows, we decouple draft generation from final delivery by staging assets inside blotato. running end-to-end integration tests against that staging layer ensures schedules fire reliably without triggering unwanted external notifications.
do you parameterize your cron triggers with dynamic test flags or isolate them into dedicated staging workspaces?
Neither, actually: the tests create a copy through the n8n API where the Schedule Trigger becomes a webhook and the Google nodes point to a stateful mock, and the date logic is covered by frozen-clock tests on the exported JSON.