hermes-test 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +60 -15
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -278,24 +278,69 @@ expect(fired).toBe(true);
278
278
  useRealTimers();
279
279
  ```
280
280
 
281
+ ## Platform requirements
282
+
283
+ | Platform | Status | Notes |
284
+ |----------|--------|-------|
285
+ | **macOS (Apple Silicon / Intel)** | ✅ Fully supported | Recommended for CI/CD |
286
+ | **Linux** | ✅ Supported | Includes NumberFormat fallback for Hermes ICU stub |
287
+
288
+ hermes-test runs on the **Hermes JavaScript engine**, the same engine that powers React Native on iOS and Android. Hermes's Intl (internationalization) support varies by platform:
289
+
290
+ - **macOS**: Full Intl support via Apple's Foundation framework (`toLocaleDateString`, `toLocaleString` etc. work correctly with any locale)
291
+ - **Android** (device): Full Intl support via Java ICU
292
+ - **Linux** (desktop/CI): Hermes's Linux Intl implementation (`PlatformIntlICU.cpp`) has an incomplete `Intl.NumberFormat`. hermes-test patches this at runtime with a deterministic fallback so locale-aware number formatting works in tests.
293
+
294
+ Linux CI is supported. macOS remains the reference environment for closest parity with iOS app behavior.
295
+
296
+ ### Linux Intl fallback behavior
297
+
298
+ On Linux, hermes-test applies small runtime fallbacks only when native behavior is clearly broken:
299
+
300
+ - `Intl.NumberFormat` + `Number.prototype.toLocaleString` (locale-sensitive numeric formatting)
301
+ - `String.prototype.toLocaleLowerCase` / `toLocaleUpperCase` (guards against ICU stub placeholders)
302
+
303
+ This is intentionally scoped. It is **not** a full CLDR implementation and does not aim to perfectly replicate every locale edge case.
304
+
305
+ If a locale isn't explicitly mapped in the number fallback, hermes-test falls back to safe defaults (`en-US`-style separators).
306
+
307
+ ### Contributing Intl improvements
308
+
309
+ If you want to improve locale behavior:
310
+
311
+ 1. Update `packages/hermes-test/src/polyfills.js` (fallback detection + formatting behavior).
312
+ 2. Add/extend tests in `examples/expo-app/src/examples/intl-locale.test.ts`.
313
+ 3. Validate on Linux (CI or local Linux container).
314
+ 4. Keep fallbacks deterministic and gated by runtime checks so working native Intl (macOS/Android) remains untouched.
315
+
316
+ <details>
317
+ <summary>Why is Linux Intl incomplete?</summary>
318
+
319
+ Hermes has three platform-specific Intl backends ([source](https://github.com/facebook/hermes/blob/main/lib/Platform/Intl/CMakeLists.txt)):
320
+
321
+ - **Apple** → `PlatformIntlApple.mm` — delegates to Foundation's `NSDateFormatter`/`NSNumberFormatter` (full CLDR locale data)
322
+ - **Android** → `PlatformIntlAndroid.cpp` — delegates to Java's `android.icu` via JNI
323
+ - **Linux/other** → `PlatformIntlICU.cpp` — intended to use ICU4C directly, but `NumberFormat` was never implemented. The [source code](https://github.com/facebook/hermes/blob/fd0e1d3ed/lib/Platform/Intl/PlatformIntlICU.cpp) contains a stub with the comment: *"This isn't right, but I didn't want to do more work for a stub."*
324
+
325
+ The Hermes team has acknowledged this is a work-in-progress ([discussion #1211](https://github.com/facebook/hermes/discussions/1211), [issue #23](https://github.com/facebook/hermes/issues/23)). Since Hermes is optimized for mobile (iOS/Android), desktop Linux has been lower priority.
326
+
327
+ See also: [Hermes IntlAPIs documentation](https://github.com/facebook/hermes/blob/main/doc/IntlAPIs.md)
328
+ </details>
329
+
330
+ ---
331
+
281
332
  ## How it works
282
333
 
283
- ```
284
- ┌──────────────┐ ┌─────────┐ ┌────────────┐
285
- │ .test.ts │────▶│ esbuild │────▶│ Hermes │
286
- │ files │ │ bundle │ │ VM eval │
287
- └──────────────┘ └─────────┘ └────────────┘
288
- │ │ │
289
- mockModule() <100ms bundle native execution
290
- spy/expect path aliases drainMicrotasks
291
- renderHook Hermes patches real React tree
292
- ```
334
+ Hermes is the JavaScript engine. The harness is the test runtime layer on top of Hermes.
293
335
 
294
- 1. **esbuild** bundles your test + source into a single IIFE (~100ms)
295
- 2. Rust CLI applies **Hermes patches** (class-extends, for-let-of)
296
- 3. **Bytecode compilation** cached .hbc for instant loading on subsequent runs
297
- 4. **Hermes VM** evaluates the bytecode same engine as your app
298
- 5. Results printed to terminal single process, no workers, no IPC
336
+ | Step | What happens |
337
+ |---|---|
338
+ | 1 | The CLI picks the test files for this run (all, filtered, or changed in watch mode). |
339
+ | 2 | The CLI generates one entry file (`.hermes-test-entry`) from those tests. |
340
+ | 3 | esbuild bundles that entry and app code into one JavaScript bundle. |
341
+ | 4 | Hermes starts and evaluates `harness.bundle.js` first (this provides `test`, `expect`, `mock`, `renderHook`, and test orchestration). |
342
+ | 5 | Hermes evaluates the test bundle, runs tests, and returns results to the CLI. |
343
+ | 6 | Bytecode cache (`.hbc`) is reused on later runs for faster startup. |
299
344
 
300
345
  ### Three-tier cache
301
346
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-test",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "26-64x faster than Jest. A test runner built for React Native and Expo. One esbuild pass, one process, zero Babel.",
5
5
  "main": "src/index.ts",
6
6
  "types": "index.d.ts",
@@ -54,9 +54,9 @@
54
54
  "react": ">=18"
55
55
  },
56
56
  "optionalDependencies": {
57
- "@hermes-test/darwin-arm64": "1.1.3",
58
- "@hermes-test/darwin-x64": "1.1.3",
59
- "@hermes-test/linux-x64": "1.1.3"
57
+ "@hermes-test/darwin-arm64": "1.1.4",
58
+ "@hermes-test/darwin-x64": "1.1.4",
59
+ "@hermes-test/linux-x64": "1.1.4"
60
60
  },
61
61
  "files": [
62
62
  "src/",