Merged
Size
S
Change Breakdown
Testing95%
Maintenance5%
#28247test: Harden polling trigger test helper against flaky OAuth2 failures (no-changelog)

Polling trigger tests hardened against OAuth2 flakiness

Flaky OAuth2 mocking in polling trigger tests has been fixed. The test helper no longer flows through fragile deep-mock proxies that caused intermittent failures — CI should now be more reliable.

CI tests for polling triggers were failing intermittently with "Cannot read properties of undefined (reading 'map')". The root cause was in the testPollingTriggerNode helper — it created a real PollContext whose request helpers flowed through the full OAuth2 signing pipeline with jest-mock-extended deep-mock credentials. These deep-mock proxies don't play well with ClientOAuth2 string operations, date math, and object spreading, causing race conditions in test execution.

Two changes make these tests reliable. First, requestOAuth2 and requestOAuth1 are overridden on the PollContext to skip the real OAuth2 flow entirely, forwarding directly to the base request helper where nock can intercept cleanly. Second, evalLlmMockHandler is explicitly set to undefined on the mocked additionalData — without this, jest-mock-extended's auto-mock creates a truthy proxy that diverts every request through the eval-mock code path unexpectedly.

These changes live in the packages/n8n-nodes-base package's test infrastructure.

View Original GitHub Description

Summary

Fixes flaky CI failures in polling trigger tests (e.g. GoogleSheetsTrigger.test.ts failing with Cannot read properties of undefined (reading 'map')).

The testPollingTriggerNode helper in TriggerHelpers.ts created a real PollContext whose request helpers flowed through the full OAuth2 signing/token pipeline with jest-mock-extended deep-mock credentials. This was fragile — deep-mock proxies interacting with ClientOAuth2 string operations, date math, and object spreading caused intermittent failures.

Two fixes:

  1. Override requestOAuth2/requestOAuth1 on the PollContext to skip the real OAuth2 flow entirely and forward directly to the base request helper (which nock can intercept cleanly).

  2. Explicitly null out evalLlmMockHandler on the mocked additionalData so jest-mock-extended's auto-mock doesn't create a truthy proxy that diverts every request through the eval-mock code path.

Related Linear tickets, Github issues, and Community forum posts

Addresses flaky CI observed in https://github.com/n8n-io/n8n/actions/runs/24182041829/job/70577629267

Review / Merge checklist

Made with Cursor

© 2026 · via Gitpulse