vitest-native 0.14.0-rc.9 → 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 (97) hide show
  1. package/README.md +76 -60
  2. package/dist/cli.d.mts +1 -3
  3. package/dist/cli.mjs +175 -63
  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-CzQazgp9.d.cts → index-DqU4YO3D.d.mts} +27 -49
  13. package/dist/index.d.mts +1 -3
  14. package/dist/index.mjs +463 -595
  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 +28 -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 +378 -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 +73 -0
  56. package/dist/native/setup.mjs +96 -70
  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 +65 -36
  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/release-readiness.md +1 -1
  80. package/package.json +119 -102
  81. package/CHANGELOG.md +0 -2491
  82. package/dist/cli.cjs +0 -1951
  83. package/dist/cli.d.cts +0 -3
  84. package/dist/ecosystem-D6e1OVOg.mjs +0 -1019
  85. package/dist/ecosystem-MFwkbnaC.cjs +0 -1099
  86. package/dist/errors-B3lJK46O.cjs +0 -75
  87. package/dist/errors-CxoBUfVJ.mjs +0 -64
  88. package/dist/index-xw43lBlv.d.mts +0 -481
  89. package/dist/memory-6EPHrJA1.cjs +0 -144
  90. package/dist/pool-B4yesGhI.cjs +0 -121
  91. package/dist/preset-map-jSFsNy1Q.cjs +0 -241
  92. package/dist/preset-modules-BoLkaeEN.cjs +0 -53
  93. package/dist/preset-modules-CG8-G82P.mjs +0 -36
  94. package/dist/presets-9f83H0WW.cjs +0 -3939
  95. package/dist/rolldown-runtime-C0BPl7ul.cjs +0 -43
  96. package/dist/worker-vitest-BfiQB8ND.cjs +0 -62
  97. package/docs/hot-default-design.md +0 -216
@@ -1,6 +1,4 @@
1
1
  import { Mock } from "vitest";
2
- //#endregion
3
- //#region src/types.d.ts
4
2
  /** Static methods available on the Image component mock. */
5
3
  interface ImageStatic {
6
4
  getSize: Mock;
@@ -244,6 +242,13 @@ interface NavigationPresetOptions {
244
242
  */
245
243
  defaultRouteParams?: Record<string, unknown>;
246
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
+ }
247
252
  interface VitestNativeOptions {
248
253
  /** Target platform. Default: 'ios' */
249
254
  platform?: "ios" | "android";
@@ -369,7 +374,9 @@ interface VitestNativeOptions {
369
374
  * or exceeds this value, also between scheduler tasks. By default a
370
375
  * constrained-memory-aware plan derives this threshold, caps automatic
371
376
  * concurrency at four, reserves main-process and worker-replacement RSS,
372
- * 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.
373
380
  * - `allowUnboundedMemory`: explicitly permit configurations where Vitest
374
381
  * cannot enforce file-boundary recycling, notably `maxWorkers: 1`. This
375
382
  * also disables the automatic worker cap and process-RSS hard stop. Use
@@ -385,24 +392,34 @@ interface VitestNativeOptions {
385
392
  * re-execution: a suite whose files import many externalized (non-React
386
393
  * Native) packages measured 55% more wall clock at the extreme — still 9x
387
394
  * stock isolation, against 13.9x with it off. Set false to trade that back,
388
- * 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).
389
399
  *
390
400
  * `'auto'` selects the bounded hot runtime when the configuration has recyclable
391
401
  * task boundaries (enough memory headroom for at least two workers) and no
392
402
  * explicit custom pool; otherwise the run keeps per-file isolation and prints the
393
403
  * reason for falling back.
394
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.
411
+ *
395
412
  * Default: `false`, as in 0.13.0: each file runs in a fresh worker, with React
396
413
  * Native reloaded per file. The hot runtime has known differences from per-file
397
414
  * isolation, listed in the troubleshooting guide.
398
415
  */
399
- hotRuntime?: boolean | "auto" | {
400
- recycleAfterFiles?: number;
401
- memoryLimit?: number;
416
+ hotRuntime?: boolean | "auto" | (HotRuntimeRecycleOptions & {
417
+ mode?: undefined;
402
418
  allowUnboundedMemory?: boolean;
403
- preserveGlobals?: string[];
404
- esmGeneration?: boolean;
405
- };
419
+ }) | (HotRuntimeRecycleOptions & {
420
+ mode: "auto";
421
+ allowUnboundedMemory?: false;
422
+ });
406
423
  /**
407
424
  * `engine: 'native'` only. How native module lookups answer.
408
425
  *
@@ -418,65 +435,26 @@ interface VitestNativeOptions {
418
435
  */
419
436
  nativeModules?: "device" | "permissive";
420
437
  }
421
- //#endregion
422
- //#region src/presets/reanimated.d.ts
423
438
  declare function reanimated(): Preset;
424
- //#endregion
425
- //#region src/presets/gesture-handler.d.ts
426
439
  declare function gestureHandler(): Preset;
427
- //#endregion
428
- //#region src/presets/safe-area.d.ts
429
440
  declare function safeAreaContext(): Preset;
430
- //#endregion
431
- //#region src/presets/navigation.d.ts
432
441
  declare function navigation(presetOptions?: NavigationPresetOptions): Preset;
433
- //#endregion
434
- //#region src/presets/async-storage.d.ts
435
442
  declare function asyncStorage(): Preset;
436
- //#endregion
437
- //#region src/presets/screens.d.ts
438
443
  declare function screens(): Preset;
439
- //#endregion
440
- //#region src/presets/expo.d.ts
441
444
  declare function expo(): Preset;
442
- //#endregion
443
- //#region src/presets/device-info.d.ts
444
445
  declare function deviceInfo(): Preset;
445
- //#endregion
446
- //#region src/presets/mmkv.d.ts
447
446
  declare function mmkv(): Preset;
448
- //#endregion
449
- //#region src/presets/netinfo.d.ts
450
447
  declare function netInfo(): Preset;
451
- //#endregion
452
- //#region src/presets/svg.d.ts
453
448
  declare function svg(): Preset;
454
- //#endregion
455
- //#region src/presets/webview.d.ts
456
449
  declare function webview(): Preset;
457
- //#endregion
458
- //#region src/presets/vector-icons.d.ts
459
450
  declare function vectorIcons(): Preset;
460
- //#endregion
461
- //#region src/presets/flash-list.d.ts
462
451
  declare function flashList(): Preset;
463
- //#endregion
464
- //#region src/presets/bottom-sheet.d.ts
465
452
  declare function bottomSheet(): Preset;
466
- //#endregion
467
- //#region src/presets/keyboard-controller.d.ts
468
453
  declare function keyboardController(): Preset;
469
- //#endregion
470
- //#region src/presets/worklets.d.ts
471
454
  declare function worklets(): Preset;
472
- //#endregion
473
- //#region src/presets/unistyles.d.ts
474
455
  declare function unistyles(): Preset;
475
- //#endregion
476
- //#region src/presets/skia.d.ts
477
456
  declare function skia(): Preset;
478
457
  declare namespace index_d_exports {
479
458
  export { asyncStorage, bottomSheet, deviceInfo, expo, flashList, gestureHandler, keyboardController, mmkv, navigation, netInfo, reanimated, safeAreaContext, screens, skia, svg, unistyles, vectorIcons, webview, worklets };
480
459
  }
481
- //#endregion
482
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-xw43lBlv.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 };