Skip to content

Build: Fix tests by adding formatted diff comparison#34715

Merged
ndelangen merged 2 commits into
nextfrom
norbert/rn-tests
May 5, 2026
Merged

Build: Fix tests by adding formatted diff comparison#34715
ndelangen merged 2 commits into
nextfrom
norbert/rn-tests

Conversation

@ndelangen
Copy link
Copy Markdown
Member

@ndelangen ndelangen commented May 5, 2026

What I did

The getDiff was inconsistent due to different formatting, by adding explicit formatting, this should be solved

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Not needed

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Tests

    • Improved Metro configuration codemod tests to normalize source formatting before diff/snapshot comparisons, making assertions more robust and consistent.
  • Refactor

    • Standardized diff/snapshot validation across Metro config tests by consolidating formatting and comparison helpers for clearer, more maintainable tests.

…e changes and updating test cases to use async/await for improved readability.
Copilot AI review requested due to automatic review settings May 5, 2026 10:01
@ndelangen ndelangen self-assigned this May 5, 2026
@ndelangen ndelangen added build Internal-facing build tooling & test updates ci:normal labels May 5, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7e0fb39-c09f-477c-84df-b6e8306f82be

📥 Commits

Reviewing files that changed from the base of the PR and between 0293537 and cf431f3.

📒 Files selected for processing (1)
  • code/lib/create-storybook/src/generators/REACT_NATIVE/metroConfig.test.ts

📝 Walkthrough

Walkthrough

Replaced raw diff assertions in Metro config codemod tests with a new getFormattedDiff(before, after, filePath) helper that uses oxfmt.format (single-quote filename-based formatting) before calling getDiff. Multiple inline snapshot expectations updated to match the normalized formatted diffs.

Changes

Metro Config Test — oxfmt Normalized Diffs

Layer / File(s) Summary
Formatting helper
code/lib/create-storybook/src/generators/REACT_NATIVE/metroConfig.test.ts
Added oxfmt.format import and new getFormattedDiff(before, after, filePath) that formats both inputs (single-quote style using path.basename(filePath)) then calls getDiff.
Test assertions
code/lib/create-storybook/src/generators/REACT_NATIVE/metroConfig.test.ts
Updated multiple tests (wrap module.exports, wrap existing wrapper, ESM import wrapper, template-literal import case, TypeScript return/type-parameter preservation, etc.) to use await getFormattedDiff(...) and updated inline snapshot diffs to match formatted output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • storybookjs/storybook#34660: Modifies the same metroConfig.test.ts suite; changes are directly related to the codemod test expectations.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 stabilizes metroConfig codemod test snapshots by normalizing before/after sources with Prettier prior to generating the textual diff, avoiding failures caused purely by formatting differences.

Changes:

  • Add a getFormattedDiff() helper that formats both inputs via prettier.format({ filepath }) before calling getDiff.
  • Update several inline snapshot assertions to compare formatted diffs.
  • Make a few test cases async and reuse a consistent filePath variable for formatting inference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…nline snapshots to use single quotes for consistency.
@ndelangen ndelangen merged commit 6750e05 into next May 5, 2026
141 checks passed
@ndelangen ndelangen deleted the norbert/rn-tests branch May 5, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants