Skip to content

test: create react-native test harness - #877

Merged
eszlamczyk merged 2 commits into
mainfrom
test/create-test-harness
Sep 24, 2026
Merged

eszlamczyk merged 2 commits into
mainfrom
test/create-test-harness

Conversation

@eszlamczyk

@eszlamczyk eszlamczyk commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

What/Why?

Follow-up to #862. The React Native package (packages/react-native-enriched-markdown) had native unit-test sources but nothing ran them: the podspec has no test_spec, there was no iOS test target, and the RN Android tests were never picked up by the standalone @enriched-markdown/android lane (flagged in the #862 review). This PR wires both platforms' library-level native unit tests into CI, mirroring how React Native itself runs RNTesterUnitTests (app-hosted XCTest).

Harness-only for now, kept green with placeholder smoke tests. The real suites from #862 (ENRMLinkPillTextStorageTests.mm, LinkPillSpanTest.kt) plug into the same target / source set when that PR merges (see __tests__/ios/README.md).

iOS

  • Restored the app-hosted EnrichedMarkdownExampleTests XCTest target in the example app's Xcode project, reusing the canonical RN-template UUIDs the shared scheme already referenced but that had been stripped from the project.
  • Podfile nests it with inherit! :complete, so tests link the same pods as the app (incl. ReactNativeEnrichedMarkdown) and run against the exact code the app ships.
  • Runs on a headless iOS Simulator via apps/react-native-example/scripts/test-ios.sh (resolves IOS_SIMULATOR_UDID -> booted -> first available iPhone). A simulator is required because the tests exercise UIKit/TextKit; there is no iOS equivalent of Robolectric.
  • SwiftLinker.swift (empty) makes the ObjC test bundle link the Swift runtime; without it CI's pinned Xcode fails at link with Undefined symbol __swift_FORCE_LOAD_$_swiftCompatibility56 (the app + RaTeX math bridge are Swift).
  • EnrichedMarkdownExampleTests.m is the placeholder smoke test.

Android

  • Added junit + robolectric and testOptions { unitTests.includeAndroidResources = true } to the RN module's android/build.gradle.
  • Runs :react-native-enriched-markdown:testDebugUnitTest (pure JVM, no emulator) from the example app's Gradle project.
  • HarnessSmokeTest.kt placeholder keeps the task from tripping Gradle 9's failOnNoDiscoveredTests.

Wiring

  • New turbo tasks test:ios / test:android on the example app.
  • Root package.json shortcuts: test:ios, test:android, test:ios-native, test:android-native (mirrors the existing test:e2e:* family). All four CI test lanes now invoke these shortcuts.
  • New CI jobs rn-ios-unit-tests and rn-android-unit-tests, gated in ci-success.

Testing

  • yarn test:ios -> ** TEST SUCCEEDED ** (app-hosted XCTest on a headless simulator).
  • yarn test:android -> BUILD SUCCESSFUL (testDebugUnitTest, Robolectric on the JVM).
  • yarn test (Jest 44/44), yarn typecheck, yarn lint unaffected and green.
  • First CI run surfaced a link failure in rn-ios-unit-tests (swiftCompatibility56); this PR includes the fix (SwiftLinker.swift).

Out of scope / follow-ups: #862's real suites attach to these targets on merge; parked review ideas - moving the example apps out of the repo, and removing the deprecated ENV / gradle-property config path before 1.1.

@eszlamczyk
eszlamczyk marked this pull request as ready for review September 24, 2026 11:37
@eszlamczyk
eszlamczyk merged commit 39e7036 into main Sep 24, 2026
14 checks passed
@eszlamczyk
eszlamczyk deleted the test/create-test-harness branch September 24, 2026 11:37
eszlamczyk added a commit that referenced this pull request Oct 9, 2026
…#890)

* fix(test): give the RN iOS test target the library header search paths

The EnrichedMarkdownExampleTests target introduced in #877 only searched
core/cpp/*, ios/internals and ios/input/internals. Any real suite importing
library headers by relative path fails to build, because those headers import
their siblings unqualified: ENRMLinkPillAttachment.h imports "ENRMUIKit.h",
which lives in ios/utils and was unreachable.

The placeholder smoke test imports nothing from the library, so the lane was
green without ever proving a header could be resolved.

vendor/ and generated/ stay out: sweeping vendor in pulls three RaTeX
xcframework module maps into scope and clang rejects the duplicate RaTeXFFI
module definitions.

Created with usage of AI tools

* test(ios): register the link pill XCTest suite in the test target

EnrichedMarkdownExample.xcodeproj is objectVersion 54 and lists sources
explicitly, so nothing under __tests__/ios is discovered automatically. #877
said the real suites "plug into the same target on merge"; that holds for
Android, where Gradle auto-discovers src/test/java, but on iOS each file needs
a PBXFileReference, a PBXBuildFile, a group entry and a Sources phase entry.

Adds ENRMLinkPillTextStorageTests.mm from #862. With this plus the header
search paths, the lane runs 13 tests instead of the placeholder alone.

This branch is red until #862 merges: the .mm it references does not exist on
main yet. It also needs the one-line NULL -> nullptr fix on #862 itself
(ENRMLinkPillTextStorageTests.mm:254) -- XCTAssertNotEqual(bitmap, NULL)
compares CGContextRef against __null, which is a hard error in ObjC++.

Created with usage of AI tools

* test(ios): auto-discover the library XCTest sources

Replaces the per-file pbxproj registration added in the previous commit.
EnrichedMarkdownExample.xcodeproj is objectVersion 54 and lists sources
explicitly, so every new __tests__/ios file needed four pbxproj entries,
and a file nobody wired stayed silently unrun - which is how the lane
passed while covering nothing.

A "Generate library test sources" phase on the test target now globs
__tests__/ios and emits an include list that one wired umbrella source,
ENRMLibraryTests.mm, pulls in. Adding a test file there needs no project
change, matching what Gradle already does for src/test/java on Android.

test-ios.sh additionally counts the "- (void)test" prototypes present and
fails when fewer tests than that ran, so a suite dropping out of the run
cannot leave the lane green.
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