Skip to content

test: implement parity fuzzing#26

Merged
mfkrause merged 3 commits into
mainfrom
test/parity-fuzzing
Jun 22, 2026
Merged

test: implement parity fuzzing#26
mfkrause merged 3 commits into
mainfrom
test/parity-fuzzing

Conversation

@mfkrause

@mfkrause mfkrause commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Chores

    • Added property-based testing framework dependency.
  • Tests

    • Enhanced testing infrastructure with comprehensive platform compatibility verification capabilities, including automated property-based fuzzing, improved test utilities, and expanded mock implementations for cross-platform validation.

@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy Preview for react-native-boost ready!

Name Link
🔨 Latest commit 7864af5
🔍 Latest deploy log https://app.netlify.com/projects/react-native-boost/deploys/6a3941fb3c33a80008bcb0b9
😎 Deploy Preview https://deploy-preview-26--react-native-boost.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

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52329ccd-ecfe-482a-9fcc-48df4be5beae

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Adds a property-based fuzz test suite to the React Native Boost parity test harness using fast-check. Introduces shared normalize/flattenStyle utilities, a writeAndImportFresh module loader, a PlatformOS type, vocabulary/generator modules for JSX spec construction, a diff.ts for order-insensitive prop comparison, and a fuzz.test.ts with three test modes.

Changes

Parity Fuzz Testing

Layer / File(s) Summary
Shared parity infrastructure
src/plugin/__tests__/parity/normalize.ts, src/plugin/__tests__/parity/generated.ts, src/plugin/__tests__/parity/mocks/Platform.ts, src/plugin/__tests__/parity/mocks/react-native.ts, src/plugin/__tests__/parity/parity.test.ts
Introduces flattenStyle/normalize for prop comparison, writeAndImportFresh for cache-busted dynamic module reloading, and the PlatformOS type alias in the Platform mock. The react-native mock's StyleSheet.flatten is changed from an identity stub to delegate to flattenStyle. Existing parity.test.ts imports normalize from the new shared module and removes its local implementations.
Harness refactoring with preamble support
src/plugin/__tests__/parity/boost.ts, src/plugin/__tests__/parity/wrapper.ts
boost.ts and wrapper.ts replace counter-based file-write-and-import with writeAndImportFresh, update os parameter typing to PlatformOS, and add an optional preamble parameter to captureBoost, captureWrapper, and captureWrapperHosts.
Fuzz vocabulary and JSX spec generator
src/plugin/__tests__/parity/fuzz/vocabulary.ts, src/plugin/__tests__/parity/fuzz/generator.ts
vocabulary.ts exports PropSpec interface and three fast-check arbitrary arrays (TEXT_VOCAB, TEXT_BLACKLIST_SAMPLE, VIEW_VOCAB) covering accessibility props, style generators, and ARIA translations. generator.ts exports ElementSpec types, elementSpecArb/platformArb, and a render(spec) function that converts specs into { preamble, jsxBody } by hoisting dynamic attrs and children into const declarations.
Diff utilities and fuzz test suite
src/plugin/__tests__/parity/fuzz/diff.ts, src/plugin/__tests__/parity/fuzz/fuzz.test.ts
diff.ts adds canonical (recursive key-sorted normalizer) and divergingKeys for order-insensitive prop comparison. fuzz.test.ts implements runCase to classify boost vs wrapper output as skipped/match/divergence, three test modes: property-based (fc.asyncProperty with optimization-rate assertion), exhaustive 3×3×3 Text accessibility matrix, and discovery mode (gated by FUZZ_DISCOVER=1) that catalogs divergence classes by frequency.
devDependency and Vitest config
package.json, src/plugin/__tests__/parity/vitest.config.parity.mts
Adds fast-check ^4.8.0 to devDependencies and extends the Vitest parity config include list to add ./fuzz/fuzz.test.ts.

Sequence Diagram(s)

sequenceDiagram
  participant fc as fast-check
  participant gen as generator.ts
  participant boost as captureBoost
  participant wrapper as captureWrapper
  participant diff as diff.ts
  participant test as fuzz.test.ts

  fc->>gen: sample elementSpecArb × platformArb
  gen-->>test: { preamble, jsxBody, os }
  test->>boost: captureBoost(os, jsxBody, preamble)
  boost-->>test: BoostBailed | BoostOptimized { which, props }
  test->>wrapper: captureWrapper(os, jsxBody, preamble)
  wrapper-->>test: Capture { which, props }
  test->>diff: divergingKeys(normalize(boostProps), normalize(wrapperProps))
  diff-->>test: string[] of diverging keys
  test-->>fc: skipped | match | divergence
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • kuatsu/react-native-boost#23: Directly builds on the parity test helper infrastructure refactored here, including changes to captureBoost in boost.ts and the preamble/writeAndImportFresh flow.

Poem

🐇 Hop, hop, through the prop maze I go,
Fuzzing JSX with fast-check in tow!
canonical sorts, divergingKeys finds,
No parity bug shall escape these binds.
The rabbit runs tests—match, skip, diverge—
Each random case bends the optimizer's curve! 🎲

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.47% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: implement parity fuzzing' directly and clearly describes the main change—adding a comprehensive parity fuzzing test suite with property-based testing using fast-check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/parity-fuzzing

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/react-native-boost/src/plugin/__tests__/parity/fuzz/fuzz.test.ts`:
- Around line 89-101: The parity test property in fc.asyncProperty is failing on
a known divergence case where iOS with numberOfLines set to -1 produces
different results (boost.numberOfLines = -1 vs wrapper.numberOfLines = 0).
Before throwing the error when result.status === 'divergence', add a conditional
check to detect if this is the known ios plus numberOfLines negative value case
by examining the os parameter and spec properties, and if matched, increment a
quarantine counter and return early instead of throwing the error. This will
temporarily suppress the known divergence until the runtime clamp parity fix is
implemented.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ea7292be-a952-45e0-babf-bc9166d7e3a1

📥 Commits

Reviewing files that changed from the base of the PR and between d012744 and d42af4c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • packages/react-native-boost/package.json
  • packages/react-native-boost/src/plugin/__tests__/parity/boost.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/fuzz/diff.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/fuzz/fuzz.test.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/fuzz/generator.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/fuzz/vocabulary.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/generated.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/mocks/Platform.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/mocks/react-native.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/normalize.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/parity.test.ts
  • packages/react-native-boost/src/plugin/__tests__/parity/vitest.config.parity.mts
  • packages/react-native-boost/src/plugin/__tests__/parity/wrapper.ts

@mfkrause mfkrause merged commit 8040a62 into main Jun 22, 2026
8 checks passed
@mfkrause mfkrause deleted the test/parity-fuzzing branch June 22, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant