-
fix(testing): template the e2e config for fresh projects instead of ast-parsing it (#36304)
发布于
2026-07-13 13:57:00 +00:00 Current Behavior
@nx/cypress's e2e configuration generator scaffolds acypress.config
from a base template (defineConfig({})), reads it back, and uses
@phenomnomnominal/tsqueryto inject thee2eblock. Loading tsquery
readsts.SyntaxKindat import time. When a workspace resolves an
incompatible TypeScript — e.g.npm installhoistingtypescript@7to
satisfy tsquery's unbounded>3.0.0peer in a workspace that pins no
TypeScript — that read throws:NX Cannot convert undefined or null to object at Object.keys (<anonymous>) at .../@phenomnomnominal/tsquery/dist/src/syntax-kind.js…and app generation fails. This is what crashes
e2e-expo/
e2e-react-native(and any cypress-scaffolded app) on the macOS CI job,
which installs test workspaces with npm. The bareappsworkspace pins
no TypeScript, so npm hoists TS 7 for tsquery's peer.Expected Behavior
For a freshly generated config the AST round-trip is unnecessary: nx
just wrote the empty base and knows every value going in (the module
shape was already decided when the base template was selected). The
generator now templates the completecypress.configdirectly via a new
buildE2EConfigFromBase(no tsquery), so generation never loads tsquery
and no longer depends on the resolved TypeScript version.The AST-based
addDefaultE2EConfigis kept for the case that genuinely
needs it — merging the e2e config into a pre-existing, possibly
user-authored config (nx g @nx/cypress:configurationon a project
that already has a config). The templated output is byte-identical
to the previous AST output, so generated files and snapshots are
unchanged.Verified: 227 cypress unit tests pass, 41 config snapshots unchanged,
ande2e-expo:e2e-macos-localpasses under npm with zero tsquery
crashes (was 53).Related Issue(s)
Surfaced by the macOS e2e (
e2e-expo/e2e-react-native) crashing
once TypeScript 7 was published to npm — cypress config generation
loaded tsquery, which reads the top-levelSyntaxKindexport that TS 7
removed.
下载附件