vitest-native 0.14.0-rc.8 → 0.14.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 (99) hide show
  1. package/README.md +91 -72
  2. package/dist/cli.d.mts +1 -3
  3. package/dist/cli.mjs +215 -76
  4. package/dist/context.d.mts +45 -0
  5. package/dist/context.mjs +243 -0
  6. package/dist/errors.d.mts +3 -0
  7. package/dist/helpers.cjs +53 -4
  8. package/dist/helpers.d.cts +1 -3
  9. package/dist/helpers.d.mts +1 -3
  10. package/dist/helpers.mjs +2 -3
  11. package/dist/host-5o48Ujzs.mjs +939 -0
  12. package/dist/{index-BSyUeoga.d.mts → index-DqU4YO3D.d.mts} +32 -53
  13. package/dist/index.d.mts +1 -3
  14. package/dist/index.mjs +464 -596
  15. package/dist/jest-compat/error-equality.mjs +127 -0
  16. package/dist/jest-compat/jest-object.mjs +149 -4
  17. package/dist/jest-compat/node-registry.mjs +233 -58
  18. package/dist/jest-compat/setup.mjs +34 -4
  19. package/dist/jest-compat.cjs +227 -52
  20. package/dist/jest-compat.d.cts +5 -6
  21. package/dist/jest-compat.d.mts +5 -6
  22. package/dist/jest-compat.mjs +204 -52
  23. package/dist/matchers.cjs +1 -2
  24. package/dist/matchers.d.cts +0 -2
  25. package/dist/matchers.d.mts +0 -2
  26. package/dist/matchers.mjs +1 -2
  27. package/dist/{memory-FYbP0_gg.mjs → memory-Couw0Esx.mjs} +31 -6
  28. package/dist/native/assets.d.mts +2 -0
  29. package/dist/native/assets.mjs +34 -0
  30. package/dist/native/babel-toolchain.mjs +190 -0
  31. package/dist/native/babel-worker.mjs +47 -0
  32. package/dist/native/boundary.mjs +23 -8
  33. package/dist/native/compile-cache.mjs +21 -9
  34. package/dist/native/coverage-v8.mjs +287 -0
  35. package/dist/native/esm-interop.mjs +216 -0
  36. package/dist/native/expo-native-modules.mjs +7 -1
  37. package/dist/native/globals.mjs +104 -6
  38. package/dist/native/hooks.mjs +271 -60
  39. package/dist/native/loader.mjs +409 -20
  40. package/dist/native/match.d.mts +24 -2
  41. package/dist/native/match.mjs +117 -12
  42. package/dist/native/metro-profile-compiler.mjs +2 -31
  43. package/dist/native/module-reset.mjs +37 -5
  44. package/dist/native/native-modules.d.mts +2 -3
  45. package/dist/native/native-modules.mjs +22 -21
  46. package/dist/native/ownership.d.mts +10 -0
  47. package/dist/native/ownership.mjs +96 -9
  48. package/dist/native/registry-compiler.mjs +6 -0
  49. package/dist/native/registry.mjs +138 -119
  50. package/dist/native/resident-health.mjs +133 -0
  51. package/dist/native/resolve.d.mts +6 -0
  52. package/dist/native/resolve.mjs +100 -9
  53. package/dist/native/rntl-hooks.mjs +157 -6
  54. package/dist/native/rntl-text-host.mjs +64 -0
  55. package/dist/native/runner.mjs +106 -1
  56. package/dist/native/setup.mjs +105 -77
  57. package/dist/native/state-manifest.mjs +14 -8
  58. package/dist/native/transform.d.mts +2 -0
  59. package/dist/native/transform.mjs +476 -59
  60. package/dist/native/worker.mjs +151 -46
  61. package/dist/{pool-DjpOjOf3.mjs → pool-CFSpNfyw.mjs} +37 -11
  62. package/dist/{preset-map-BlBriTA0.mjs → preset-map-CogjYmSw.mjs} +4 -19
  63. package/dist/preset-modules.mjs +2 -11
  64. package/dist/{presets--zrEWQC2.mjs → presets-CXDyg51l.mjs} +65 -82
  65. package/dist/presets.d.mts +1 -1
  66. package/dist/presets.mjs +1 -1
  67. package/dist/report-error.d.mts +20 -0
  68. package/dist/report-error.mjs +145 -0
  69. package/dist/rntl-support.d.mts +12 -0
  70. package/dist/rntl-support.mjs +189 -0
  71. package/dist/{rolldown-runtime-BhDjJH2R.mjs → rolldown-runtime-D70C1uOS.mjs} +1 -2
  72. package/dist/serializer.cjs +1 -2
  73. package/dist/serializer.d.cts +1 -3
  74. package/dist/serializer.d.mts +1 -3
  75. package/dist/serializer.mjs +1 -2
  76. package/dist/setup.mjs +95 -156
  77. package/dist/{worker-vitest-BGPo0ek6.mjs → worker-vitest-CILPFeRX.mjs} +2 -3
  78. package/docs/migrating-from-jest.md +76 -12
  79. package/docs/migrating-from-vitest-react-native.md +1 -1
  80. package/docs/release-readiness.md +6 -5
  81. package/docs/versioning.md +1 -1
  82. package/package.json +121 -103
  83. package/CHANGELOG.md +0 -2475
  84. package/dist/cli.cjs +0 -1924
  85. package/dist/cli.d.cts +0 -3
  86. package/dist/ecosystem-D6e1OVOg.mjs +0 -1019
  87. package/dist/ecosystem-MFwkbnaC.cjs +0 -1099
  88. package/dist/errors-B3lJK46O.cjs +0 -75
  89. package/dist/errors-CxoBUfVJ.mjs +0 -64
  90. package/dist/index-bZ7AHqLc.d.cts +0 -482
  91. package/dist/memory-6EPHrJA1.cjs +0 -144
  92. package/dist/pool-B4yesGhI.cjs +0 -121
  93. package/dist/preset-map-jSFsNy1Q.cjs +0 -241
  94. package/dist/preset-modules-BoLkaeEN.cjs +0 -53
  95. package/dist/preset-modules-CG8-G82P.mjs +0 -36
  96. package/dist/presets-9f83H0WW.cjs +0 -3939
  97. package/dist/rolldown-runtime-C0BPl7ul.cjs +0 -43
  98. package/dist/worker-vitest-BfiQB8ND.cjs +0 -62
  99. package/docs/hot-default-design.md +0 -216
@@ -1,5 +1,4 @@
1
1
  import { Mock } from "vitest";
2
- //#region src/types.d.ts
3
2
  /** Static methods available on the Image component mock. */
4
3
  interface ImageStatic {
5
4
  getSize: Mock;
@@ -243,6 +242,13 @@ interface NavigationPresetOptions {
243
242
  */
244
243
  defaultRouteParams?: Record<string, unknown>;
245
244
  }
245
+ /** The `hotRuntime` object form's recycling options, shared by both of its modes. */
246
+ interface HotRuntimeRecycleOptions {
247
+ recycleAfterFiles?: number;
248
+ memoryLimit?: number;
249
+ preserveGlobals?: string[];
250
+ esmGeneration?: boolean;
251
+ }
246
252
  interface VitestNativeOptions {
247
253
  /** Target platform. Default: 'ios' */
248
254
  platform?: "ios" | "android";
@@ -368,7 +374,9 @@ interface VitestNativeOptions {
368
374
  * or exceeds this value, also between scheduler tasks. By default a
369
375
  * constrained-memory-aware plan derives this threshold, caps automatic
370
376
  * concurrency at four, reserves main-process and worker-replacement RSS,
371
- * and stops before crossing 90% of the host/container limit.
377
+ * and stops before crossing 90% of the host/container limit. A worker count
378
+ * you set (`maxWorkers`, `--maxWorkers` or `VITEST_MAX_WORKERS`) is capped
379
+ * only by what that memory envelope admits.
372
380
  * - `allowUnboundedMemory`: explicitly permit configurations where Vitest
373
381
  * cannot enforce file-boundary recycling, notably `maxWorkers: 1`. This
374
382
  * also disables the automatic worker cap and process-RSS hard stop. Use
@@ -384,24 +392,34 @@ interface VitestNativeOptions {
384
392
  * re-execution: a suite whose files import many externalized (non-React
385
393
  * Native) packages measured 55% more wall clock at the extreme — still 9x
386
394
  * stock isolation, against 13.9x with it off. Set false to trade that back,
387
- * accepting that a package holding state across files will keep it.
395
+ * accepting that a package holding state across files will keep it. While it
396
+ * is on, hot workers leave Node's V8 compile cache off, because every file
397
+ * would add an entry per re-evaluated module (unless `NODE_COMPILE_CACHE` is
398
+ * set, which turns the cache on before vitest-native runs).
388
399
  *
389
400
  * `'auto'` selects the bounded hot runtime when the configuration has recyclable
390
401
  * task boundaries (enough memory headroom for at least two workers) and no
391
- * explicit custom pool; otherwise the run keeps per-file isolation. Set
392
- * explicitly, it prints the reason for falling back; as the default it falls
393
- * back quietly (`diagnostics: true` shows the reason).
402
+ * explicit custom pool; otherwise the run keeps per-file isolation and prints the
403
+ * reason for falling back.
404
+ *
405
+ * - `mode: 'auto'` in the object form selects the same way, with the object's
406
+ * recycling options applied when the hot runtime runs:
407
+ * `{ mode: 'auto', memoryLimit: 2 * 1024 ** 3 }`. Without `mode`, the object
408
+ * form requires the hot runtime, as `true` does. Cannot be combined with
409
+ * `allowUnboundedMemory: true`. Worker count and process-RSS limits still come
410
+ * from the memory plan; `memoryLimit: 0` turns the heap threshold off.
394
411
  *
395
- * Default: `'auto'`. `false` always runs each file in a fresh worker, with React
396
- * Native reloaded per file.
412
+ * Default: `false`, as in 0.13.0: each file runs in a fresh worker, with React
413
+ * Native reloaded per file. The hot runtime has known differences from per-file
414
+ * isolation, listed in the troubleshooting guide.
397
415
  */
398
- hotRuntime?: boolean | "auto" | {
399
- recycleAfterFiles?: number;
400
- memoryLimit?: number;
416
+ hotRuntime?: boolean | "auto" | (HotRuntimeRecycleOptions & {
417
+ mode?: undefined;
401
418
  allowUnboundedMemory?: boolean;
402
- preserveGlobals?: string[];
403
- esmGeneration?: boolean;
404
- };
419
+ }) | (HotRuntimeRecycleOptions & {
420
+ mode: "auto";
421
+ allowUnboundedMemory?: false;
422
+ });
405
423
  /**
406
424
  * `engine: 'native'` only. How native module lookups answer.
407
425
  *
@@ -417,65 +435,26 @@ interface VitestNativeOptions {
417
435
  */
418
436
  nativeModules?: "device" | "permissive";
419
437
  }
420
- //#endregion
421
- //#region src/presets/reanimated.d.ts
422
438
  declare function reanimated(): Preset;
423
- //#endregion
424
- //#region src/presets/gesture-handler.d.ts
425
439
  declare function gestureHandler(): Preset;
426
- //#endregion
427
- //#region src/presets/safe-area.d.ts
428
440
  declare function safeAreaContext(): Preset;
429
- //#endregion
430
- //#region src/presets/navigation.d.ts
431
441
  declare function navigation(presetOptions?: NavigationPresetOptions): Preset;
432
- //#endregion
433
- //#region src/presets/async-storage.d.ts
434
442
  declare function asyncStorage(): Preset;
435
- //#endregion
436
- //#region src/presets/screens.d.ts
437
443
  declare function screens(): Preset;
438
- //#endregion
439
- //#region src/presets/expo.d.ts
440
444
  declare function expo(): Preset;
441
- //#endregion
442
- //#region src/presets/device-info.d.ts
443
445
  declare function deviceInfo(): Preset;
444
- //#endregion
445
- //#region src/presets/mmkv.d.ts
446
446
  declare function mmkv(): Preset;
447
- //#endregion
448
- //#region src/presets/netinfo.d.ts
449
447
  declare function netInfo(): Preset;
450
- //#endregion
451
- //#region src/presets/svg.d.ts
452
448
  declare function svg(): Preset;
453
- //#endregion
454
- //#region src/presets/webview.d.ts
455
449
  declare function webview(): Preset;
456
- //#endregion
457
- //#region src/presets/vector-icons.d.ts
458
450
  declare function vectorIcons(): Preset;
459
- //#endregion
460
- //#region src/presets/flash-list.d.ts
461
451
  declare function flashList(): Preset;
462
- //#endregion
463
- //#region src/presets/bottom-sheet.d.ts
464
452
  declare function bottomSheet(): Preset;
465
- //#endregion
466
- //#region src/presets/keyboard-controller.d.ts
467
453
  declare function keyboardController(): Preset;
468
- //#endregion
469
- //#region src/presets/worklets.d.ts
470
454
  declare function worklets(): Preset;
471
- //#endregion
472
- //#region src/presets/unistyles.d.ts
473
455
  declare function unistyles(): Preset;
474
- //#endregion
475
- //#region src/presets/skia.d.ts
476
456
  declare function skia(): Preset;
477
457
  declare namespace index_d_exports {
478
458
  export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, netInfo, reanimated, safeAreaContext, screens, skia, svg, unistyles, vectorIcons, webview, worklets };
479
459
  }
480
- //#endregion
481
460
  export { VitestNativeOptions as C, ReactNativeMock as S, navigation as _, keyboardController as a, reanimated as b, vectorIcons as c, netInfo as d, mmkv as f, asyncStorage as g, screens as h, worklets as i, webview as l, expo as m, skia as n, bottomSheet as o, deviceInfo as p, unistyles as r, flashList as s, index_d_exports as t, svg as u, safeAreaContext as v, Preset as x, gestureHandler as y };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { C as VitestNativeOptions, S as ReactNativeMock, t as index_d_exports, x as Preset } from "./index-BSyUeoga.mjs";
1
+ import { C as VitestNativeOptions, S as ReactNativeMock, t as index_d_exports, x as Preset } from "./index-DqU4YO3D.mjs";
2
2
  import { Plugin } from "vite";
3
- //#region src/plugin.d.ts
4
3
  /**
5
4
  * Preset names switched off by the object form of the `presets` option.
6
5
  *
@@ -11,5 +10,4 @@ import { Plugin } from "vite";
11
10
  */
12
11
  export declare function disabledPresetNames(presets: unknown): Set<string>;
13
12
  export declare function reactNative(options?: VitestNativeOptions): Plugin;
14
- //#endregion
15
13
  export { type Preset, type ReactNativeMock, type VitestNativeOptions, index_d_exports as presets };