Skip to content

fix(vitest-angular): normalize snapshot whitespace#2237

Merged
brandonroberts merged 3 commits intoanalogjs:alphafrom
benpsnyder:fix/2220-snapshot-whitespace
Apr 13, 2026
Merged

fix(vitest-angular): normalize snapshot whitespace#2237
brandonroberts merged 3 commits intoanalogjs:alphafrom
benpsnyder:fix/2220-snapshot-whitespace

Conversation

@benpsnyder
Copy link
Copy Markdown
Contributor

PR Checklist

Closes #2220

Affected scope

  • Primary scope: vitest-angular
  • Secondary scopes:

Recommended merge strategy for maintainer [optional]

  • Squash merge
  • Rebase merge
  • Other

Commit preservation note [optional]

What is the new behavior?

Fixture snapshots now normalize serializer output to remove trailing whitespace at the end of lines and collapse repeated blank lines.

This keeps inline snapshots stable when formatters strip trailing spaces, and it removes extra empty rows left behind after serializer cleanup removes Angular comment noise.

The change stays inside the Angular fixture snapshot serializer and adds focused regression coverage for the whitespace normalization behavior.

Test plan

  • nx format:check
  • pnpm build
  • pnpm test
  • Manual verification

Commands run:

  • pnpm exec vitest run --config packages/vitest-angular/vite.config.ts packages/vitest-angular/src/lib/snapshot-serializers/angular-fixture.spec.ts
  • pnpm nx build vitest-angular

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This is intentionally conservative normalization: it only trims trailing spaces and collapses runs of empty lines in the final printed snapshot output.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 5, 2026

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit d7fb4d0
🔍 Latest deploy log https://app.netlify.com/projects/analog-blog/deploys/69db222f73719b0008786cf5
😎 Deploy Preview https://deploy-preview-2237--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 5, 2026

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit d7fb4d0
🔍 Latest deploy log https://app.netlify.com/projects/analog-app/deploys/69db222fdb54800008a2d66c
😎 Deploy Preview https://deploy-preview-2237--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a3af6b13-7d4f-4cc9-85c9-4de85568a737

📥 Commits

Reviewing files that changed from the base of the PR and between b904975 and d7fb4d0.

⛔ Files ignored due to path filters (1)
  • tests/vitest-angular/src/snapshot-serializers/__snapshots__/angular-fixture-snapshot.spec.ts.snap is excluded by !**/*.snap and included by tests/**
📒 Files selected for processing (1)
  • packages/vitest-angular/src/lib/snapshot-serializers/angular-fixture.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/vitest-angular/src/lib/snapshot-serializers/angular-fixture.spec.ts

📝 Walkthrough

Walkthrough

Added a normalizeSnapshotOutput helper that trims trailing spaces/tabs on each line and collapses runs of three or more consecutive newlines into two. The Angular fixture snapshot serializer now applies this normalization to its serialized output. Two new tests were added to validate normalization behavior for trailing whitespace, repeated blank lines, and mixed whitespace within serialized component fixture outputs. No public API or exported declarations were changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR title follows Conventional Commit style with supported scope (vitest-angular) and clearly summarizes the main change (whitespace normalization in snapshots).
Description check ✅ Passed PR description directly relates to the changeset, explains the problem (trailing whitespace and empty rows in snapshots) and solution (normalization in serializer output).
Linked Issues check ✅ Passed Changes fully address #2220 objectives: trailing whitespace is trimmed via normalizeSnapshotOutput(), empty rows are collapsed, and fix is implemented at serializer level with regression test coverage.
Out of Scope Changes check ✅ Passed All changes are scoped to vitest-angular snapshot serializer normalization and related test coverage; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@benpsnyder benpsnyder marked this pull request as ready for review April 5, 2026 08:11
@github-actions github-actions Bot added the scope:vitest-angular Changes in @analogjs/vitest-angular label Apr 5, 2026
@benpsnyder
Copy link
Copy Markdown
Contributor Author

@brandonroberts ready

Copy link
Copy Markdown
Member

@brandonroberts brandonroberts left a comment

Choose a reason for hiding this comment

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

Beta branch

Copy link
Copy Markdown
Member

@brandonroberts brandonroberts left a comment

Choose a reason for hiding this comment

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

LGTM

@brandonroberts brandonroberts merged commit 8853dc0 into analogjs:alpha Apr 13, 2026
21 checks passed
@brandonroberts brandonroberts deleted the fix/2220-snapshot-whitespace branch April 13, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:vitest-angular Changes in @analogjs/vitest-angular

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants