vitest-native 0.8.0 → 0.10.0

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 (65) hide show
  1. package/CHANGELOG.md +1063 -0
  2. package/README.md +47 -2
  3. package/dist/cli.cjs +642 -0
  4. package/dist/cli.d.cts +4 -0
  5. package/dist/cli.d.mts +4 -0
  6. package/dist/cli.mjs +638 -0
  7. package/dist/ecosystem-CO5vqExO.mjs +318 -0
  8. package/dist/ecosystem-IuZ-Gv0R.cjs +356 -0
  9. package/dist/errors-Dm5yLNTF.mjs +64 -0
  10. package/dist/errors-flXDIeWk.cjs +75 -0
  11. package/dist/errors.d.mts +46 -0
  12. package/dist/errors.mjs +78 -0
  13. package/dist/helpers.cjs +6 -23
  14. package/dist/helpers.d.cts +0 -6
  15. package/dist/helpers.d.mts +0 -6
  16. package/dist/helpers.mjs +6 -23
  17. package/dist/{index-vlK4zxuK.d.mts → index-BJL4cQ-l.d.cts} +22 -7
  18. package/dist/{index-YjjYELG7.d.cts → index-CvCU0cLl.d.mts} +20 -9
  19. package/dist/index.d.mts +8 -6
  20. package/dist/index.mjs +563 -232
  21. package/dist/jest-compat/interop.mjs +15 -0
  22. package/dist/jest-compat/setup.mjs +164 -5
  23. package/dist/matchers.cjs +16 -7
  24. package/dist/matchers.mjs +16 -7
  25. package/dist/native/boundary.mjs +108 -30
  26. package/dist/native/compile-cache.mjs +10 -5
  27. package/dist/native/explain.mjs +69 -0
  28. package/dist/native/hooks.mjs +151 -4
  29. package/dist/native/loader.mjs +61 -12
  30. package/dist/native/match.mjs +107 -8
  31. package/dist/native/module-reset.mjs +63 -0
  32. package/dist/native/registry.mjs +540 -0
  33. package/dist/native/reset.mjs +18 -12
  34. package/dist/native/resolve.d.mts +22 -0
  35. package/dist/native/resolve.mjs +21 -13
  36. package/dist/native/runner.mjs +34 -7
  37. package/dist/native/setup.mjs +19 -3
  38. package/dist/native/transform.mjs +195 -21
  39. package/dist/native/worker.mjs +69 -17
  40. package/dist/pool-Bcxp4Qrg.mjs +118 -0
  41. package/dist/pool-CFND7plG.cjs +122 -0
  42. package/dist/{preset-map-DCWaM08s.mjs → preset-map-BpDG_D5m.mjs} +1 -1
  43. package/dist/{preset-map-BY9zk9Pj.cjs → preset-map-DxilQ4pI.cjs} +1 -1
  44. package/dist/{presets-7eMfp7o2.cjs → presets-BGTqVH6C.cjs} +227 -52
  45. package/dist/{presets-23FJ76O4.mjs → presets-CK85x8ey.mjs} +222 -53
  46. package/dist/presets.d.mts +2 -2
  47. package/dist/presets.mjs +2 -2
  48. package/dist/rntl-matchers.d.ts +35 -0
  49. package/dist/serializer.cjs +33 -3
  50. package/dist/serializer.mjs +33 -3
  51. package/dist/setup.mjs +544 -193
  52. package/docs/hot-default-design.md +129 -0
  53. package/docs/migrating-from-jest.md +43 -7
  54. package/docs/migrating-from-vitest-react-native.md +1 -1
  55. package/docs/release-readiness.md +24 -6
  56. package/docs/versioning.md +133 -0
  57. package/package.json +40 -38
  58. package/dist/index.cjs +0 -643
  59. package/dist/index.d.cts +0 -14
  60. package/dist/pool-B7LBfcMQ.mjs +0 -67
  61. package/dist/pool-p54QV1dQ.cjs +0 -69
  62. package/dist/presets.cjs +0 -17
  63. package/dist/presets.d.cts +0 -2
  64. package/dist/setup.cjs +0 -2514
  65. package/dist/setup.d.cts +0 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # vitest-native
2
2
 
3
+ [![RN fidelity](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fdanfry1%2Fvitest-native%2Fmain%2Fpackages%2Fvitest-native%2Fcrosscheck%2Ffidelity-badge.json)](https://github.com/danfry1/vitest-native/blob/main/website/guide/fidelity.md)
4
+
3
5
  Run your React Native tests under Vitest, against **real React Native** — the same JavaScript that ships in your app, with only the native-module boundary mocked. That is the default and the point of the project. A lightweight pure-JS mock engine is available as an opt-in for fast, RN-free unit tests.
4
6
 
5
7
  > **Beta.** The release-supported native engine is validated across React Native 0.81–0.86,
@@ -217,6 +219,18 @@ the app/test module graph for every file. It also restores direct `process.env`
217
219
  file-created globals, RN event subscriptions, dimensions, timers, and plugin mock state between
218
220
  files. A dedicated one-worker CI test exercises this cross-file isolation contract.
219
221
 
222
+ **Known limitation.** Because React Native stays resident, state held inside React Native's own
223
+ internal modules is _not_ reset between files — the per-file reset deliberately does not reach into
224
+ third-party or RN-internal module internals, because doing so generically is unsafe. Suites that
225
+ lean on deep resident-RN-internal state can therefore see cross-file interference under the hot
226
+ runtime that they would not see under the default per-file isolation. The clearest example is heavy
227
+ cross-file `Animated` usage, where animations driven in one file can alter how a later file renders.
228
+ The tell-tale sign is a test that passes in isolation but fails when run after other files; if you
229
+ see that, move the affected suite (or the project) back to the default per-file isolation. This is
230
+ why the hot runtime is opt-in and experimental rather than the default; closing the gap for all
231
+ suites depends on a per-file module reset inside a persistent worker that Vitest does not yet
232
+ provide.
233
+
220
234
  For additional leak containment:
221
235
 
222
236
  ```ts
@@ -620,6 +634,33 @@ When supported `@testing-library/react-native` 12–14 is installed, `vitest-nat
620
634
  auto-registers its custom matchers across each major's export layout. No manual
621
635
  `extend(matchers)` call or setup file is needed.
622
636
 
637
+ ### TypeScript
638
+
639
+ The matchers run without any setup, but their **types** need one line. RNTL declares
640
+ them only for Jest — it augments the global `jest` namespace and `@jest/expect`, and
641
+ neither reaches Vitest's `Assertion` — so without this they are
642
+ `Property 'toHaveTextContent' does not exist on type 'Assertion<...>'` even though the
643
+ assertion works at runtime.
644
+
645
+ Reference the types once, anywhere in the project:
646
+
647
+ ```ts
648
+ /// <reference types="vitest-native/rntl-matchers" />
649
+ ```
650
+
651
+ or add it to `compilerOptions.types` in `tsconfig.json`:
652
+
653
+ ```json
654
+ { "compilerOptions": { "types": ["vitest-native/rntl-matchers"] } }
655
+ ```
656
+
657
+ It is opt-in rather than automatic because `@testing-library/react-native` is an
658
+ optional peer: a type import of an absent package is invisible under
659
+ `skipLibCheck: true` (React Native's default) but reports `TS2307` under
660
+ `skipLibCheck: false`, which would break projects that use the mock engine without
661
+ RNTL. Referencing nothing loads nothing — the file is not part of the program unless
662
+ asked for.
663
+
623
664
  The following matchers become available on `expect()`:
624
665
 
625
666
  | Matcher | Description |
@@ -833,7 +874,7 @@ Every release must pass:
833
874
 
834
875
  - Linux on Node 20.19 and 22.13, plus macOS and Windows on Node 22.13.
835
876
  - The mock, native iOS, native Android, hot-runtime, isolation, and 100-file soak suites.
836
- - React Native 0.81–0.85 against both locked and newest-supported Vitest 4.
877
+ - React Native 0.81–0.86 against both locked and newest-supported Vitest 4.
837
878
  - Packed bare RN 0.83/RNTL 12, Expo 56/RNTL 13, Vite 8 monorepo/RNTL 14, and RN 0.86 consumers.
838
879
  - Mock-versus-real-RN behavioral cross-checks, example-app tests, typecheck, lint, formatting, and
839
880
  package export analysis.
@@ -841,6 +882,10 @@ Every release must pass:
841
882
  Current React Native edge releases are also tested weekly. See
842
883
  [the release-readiness policy](docs/release-readiness.md) for the exact gates and stability labels.
843
884
 
885
+ For what is *promised* rather than what is tested — which exports and options are protected by
886
+ semver, which are experimental, how the version ranges above may move, and what 1.0 will mean —
887
+ see [versioning and stability](docs/versioning.md).
888
+
844
889
  ---
845
890
 
846
891
  ## Requirements
@@ -850,7 +895,7 @@ Current React Native edge releases are also tested weekly. See
850
895
  | `react` | >= 18; use RN's matching React version |
851
896
  | `vite` | ^6.4.2, ^7.3.2, or ^8.0.5 |
852
897
  | `vitest` | 4.x |
853
- | `node` | >= 20; RN/RNTL may impose a higher floor |
898
+ | `node` | >= 20.19; RN/RNTL may impose a higher floor |
854
899
  | `react-native` (native engine) | 0.81–0.86 validated |
855
900
  | `@react-native/babel-preset` (native engine) | Match the installed React Native minor |
856
901
  | `@testing-library/react-native` (optional) | 12.x, 13.x, or 14.x |