test(nx-payload): optimize test suite and add plugin unit coverage#429
Conversation
- Unblock application and preset generator specs by mocking createProjectGraphAsync per spec file (scoped, preserves spyOn in migration specs); remove describe.skip and daemon boilerplate - Remove stale 'should disable react compiler' test; fix path alias assertion (./apps/… prefix) - Delete legacy.spec.ts e2e (500s, deprecated pattern; structural coverage owned by unit tests) - Trim quick.spec.ts e2e: remove 5 redundant target execution tests, keep setup-path uniqueness and one build smoke test - Replace skip-docker config with main; Linux runs main, mac/Windows keep quick for cross-platform coverage - Fix Playwright preinstall: skip cache/install/deps on macOS/Windows - Fix Dockerfile template: node:20-alpine → node:22-alpine - Add createPayloadTargets spec: graphQL branching, all 7 targets, env vars, project-scoped container references - Add normalizePluginOptions spec: all defaults and overrides - Add createPayloadNodes spec: routing, cache, project structure, configFile derivation, graphQL state propagation
|
|
|
View your CI Pipeline Execution ↗ for commit 088daf0
☁️ Nx Cloud last updated this comment at |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #429 +/- ##
===========================================
+ Coverage 74.51% 91.11% +16.60%
===========================================
Files 57 29 -28
Lines 1036 563 -473
Branches 220 148 -72
===========================================
- Hits 772 513 -259
+ Misses 264 50 -214 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes the nx-payload test strategy by replacing slow/deprecated E2E coverage with fast unit tests, unblocking previously skipped generator specs via targeted Nx graph mocking, and simplifying CI E2E matrix configuration while keeping cross-platform confidence.
Changes:
- Added unit test coverage for
createPayloadTargets,normalizePluginOptions, andcreatePayloadNodes(including GraphQL branching + caching behavior). - Unskipped
applicationandpresetgenerator specs by mockingcreateProjectGraphAsync(removing daemon/env boilerplate). - Trimmed/remapped E2E suites and CI matrix, and updated the app Dockerfile template base image to
node:22-alpine.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/nx-payload/src/utils/create-payload-targets.spec.ts | Adds unit coverage for inferred Nx target generation (GraphQL branching, env/cwd/inputs, DX commands). |
| packages/nx-payload/src/plugins/utils/normalize-plugin-options.spec.ts | Adds unit coverage for plugin option defaults and overrides. |
| packages/nx-payload/src/plugins/utils/create-payload-nodes.spec.ts | Adds unit coverage for node inference routing, config path derivation, hashing/caching, GraphQL state propagation. |
| packages/nx-payload/src/generators/preset/preset.spec.ts | Unskips preset generator tests by mocking createProjectGraphAsync; removes daemon toggling boilerplate. |
| packages/nx-payload/src/generators/application/files/Dockerfile__tmpl__ | Updates generated Dockerfile base image to node:22-alpine. |
| packages/nx-payload/src/generators/application/application.spec.ts | Unskips application generator tests by mocking createProjectGraphAsync; removes daemon toggling boilerplate and drops a stale test. |
| packages/nx-payload/src/generators/application/snapshots/application.spec.ts.snap | Updates snapshot to reflect the new Dockerfile base image. |
| e2e/nx-payload-e2e/src/nx-payload.quick.spec.ts | Trims quick E2E coverage by removing redundant target-execution tests (keeps a build smoke test). |
| e2e/nx-payload-e2e/src/nx-payload.legacy.spec.ts | Removes deprecated/slow legacy E2E suite. |
| e2e/nx-payload-e2e/project.json | Replaces skip-docker config with main configuration mapping. |
| .github/workflows/e2e-matrix.yml | Updates E2E matrix to run main on Linux, keeps quick on macOS/Windows, and gates Playwright browser caching/install to Linux. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes COD-274
Summary
application.spec.tsandpreset.spec.tsby mockingcreateProjectGraphAsyncper spec file (scoped to generator specs only, preservingspyOnusage in migration specs); removeddescribe.skipand daemon manipulation boilerplateshould disable react compilertest; fixed path alias assertionlegacy.spec.tse2e (~500s, deprecated non-inference pattern — structural coverage now owned by fast unit tests)quick.spec.tse2e: removed 5 redundant target execution tests already covered bymain.spec.ts; kept setup-path uniqueness and one build smoke testskip-dockere2e config withmain; Linux runsmain, macOS/Windows keepquickfor cross-platform coveragenode:20-alpine→node:22-alpinecreatePayloadTargetsspec: graphQL branching, all 7 targets, env vars, project-scoped container referencesnormalizePluginOptionsspec: all defaults and overridescreatePayloadNodesspec: routing logic, cache behaviour, project structure, configFile derivation, graphQL state propagationTest plan
pnpm nx test nx-payload— 12 suites, 92 tests, ~3.5s