Skip to content

test(nx-payload): optimize test suite and add plugin unit coverage#429

Merged
hakalb merged 2 commits into
mainfrom
cod-274-unit-tests-are-very-slow
May 11, 2026
Merged

test(nx-payload): optimize test suite and add plugin unit coverage#429
hakalb merged 2 commits into
mainfrom
cod-274-unit-tests-are-very-slow

Conversation

@hakalb

@hakalb hakalb commented May 11, 2026

Copy link
Copy Markdown
Member

Closes COD-274

Summary

  • Unblocked application.spec.ts and preset.spec.ts by mocking createProjectGraphAsync per spec file (scoped to generator specs only, preserving spyOn usage in migration specs); removed describe.skip and daemon manipulation boilerplate
  • Removed stale should disable react compiler test; fixed path alias assertion
  • Deleted legacy.spec.ts e2e (~500s, deprecated non-inference pattern — structural coverage now owned by fast unit tests)
  • Trimmed quick.spec.ts e2e: removed 5 redundant target execution tests already covered by main.spec.ts; kept setup-path uniqueness and one build smoke test
  • Replaced skip-docker e2e config with main; Linux runs main, macOS/Windows keep quick for cross-platform coverage
  • Fixed Playwright preinstall: skipped on macOS/Windows (they never run docker/ui tests)
  • Fixed Dockerfile generator template: node:20-alpinenode:22-alpine
  • Added createPayloadTargets spec: graphQL branching, all 7 targets, env vars, project-scoped container references
  • Added normalizePluginOptions spec: all defaults and overrides
  • Added createPayloadNodes spec: routing logic, cache behaviour, project structure, configFile derivation, graphQL state propagation

Test plan

  • pnpm nx test nx-payload — 12 suites, 92 tests, ~3.5s

hakalb added 2 commits May 11, 2026 09:56
- 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
Copilot AI review requested due to automatic review settings May 11, 2026 08:02
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@nx-cloud

nx-cloud Bot commented May 11, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 088daf0

Command Status Duration Result
nx affected -t lint,test,build -c ci ✅ Succeeded 26s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-11 08:04:05 UTC

@github-actions github-actions Bot added the preview-deploy PR Trigger: run continuous preview deployments label May 11, 2026
@sentry

sentry Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.11%. Comparing base (e966ce6) to head (088daf0).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and createPayloadNodes (including GraphQL branching + caching behavior).
  • Unskipped application and preset generator specs by mocking createProjectGraphAsync (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.

@hakalb hakalb added this pull request to the merge queue May 11, 2026
Merged via the queue into main with commit 8a75ba2 May 11, 2026
24 checks passed
@hakalb hakalb deleted the cod-274-unit-tests-are-very-slow branch May 11, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview-deploy PR Trigger: run continuous preview deployments

Development

Successfully merging this pull request may close these issues.

2 participants