vitest-native 0.14.0-rc.11 → 0.14.0-rc.13

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 (59) hide show
  1. package/README.md +4 -0
  2. package/dist/cli.d.mts +1 -3
  3. package/dist/cli.mjs +15 -24
  4. package/dist/context.d.mts +5 -0
  5. package/dist/context.mjs +5 -0
  6. package/dist/{errors-CxoBUfVJ.mjs → errors-ijs8WAcX.mjs} +1 -2
  7. package/dist/errors.d.mts +1 -0
  8. package/dist/helpers.cjs +2 -4
  9. package/dist/helpers.d.cts +1 -3
  10. package/dist/helpers.d.mts +1 -3
  11. package/dist/helpers.mjs +2 -3
  12. package/dist/{host-C3wt9zUE.mjs → host-CzQ2Jpia.mjs} +281 -51
  13. package/dist/{index-CPEAYjaQ.d.mts → index-DqU4YO3D.d.mts} +20 -46
  14. package/dist/index.d.mts +1 -3
  15. package/dist/index.mjs +125 -35
  16. package/dist/jest-compat.cjs +3 -6
  17. package/dist/jest-compat.d.cts +1 -5
  18. package/dist/jest-compat.d.mts +1 -5
  19. package/dist/jest-compat.mjs +2 -4
  20. package/dist/matchers.cjs +1 -2
  21. package/dist/matchers.d.cts +0 -2
  22. package/dist/matchers.d.mts +0 -2
  23. package/dist/matchers.mjs +1 -2
  24. package/dist/{memory-BFxB285Z.mjs → memory-B9IFtT_r.mjs} +2 -3
  25. package/dist/native/babel-toolchain.mjs +128 -2
  26. package/dist/native/boundary.mjs +22 -5
  27. package/dist/native/coverage-v8.mjs +287 -0
  28. package/dist/native/expo-native-modules.mjs +7 -1
  29. package/dist/native/globals.mjs +65 -4
  30. package/dist/native/hooks.mjs +117 -30
  31. package/dist/native/loader.mjs +356 -11
  32. package/dist/native/match.d.mts +23 -1
  33. package/dist/native/match.mjs +100 -5
  34. package/dist/native/native-modules.d.mts +2 -0
  35. package/dist/native/native-modules.mjs +18 -0
  36. package/dist/native/ownership.d.mts +10 -0
  37. package/dist/native/ownership.mjs +96 -9
  38. package/dist/native/registry.mjs +66 -59
  39. package/dist/native/resident-health.mjs +133 -0
  40. package/dist/native/runner.mjs +73 -0
  41. package/dist/native/setup.mjs +13 -6
  42. package/dist/native/state-manifest.mjs +1 -0
  43. package/dist/native/transform.mjs +120 -23
  44. package/dist/native/worker.mjs +39 -6
  45. package/dist/{pool-DUOe-n1k.mjs → pool-DQ2EE9e6.mjs} +30 -10
  46. package/dist/{preset-map-L1-vD19T.mjs → preset-map-n08Oz-ZL.mjs} +2 -4
  47. package/dist/{preset-modules-Bt6k_Wdw.mjs → preset-modules-CNrYP5IR.mjs} +2 -3
  48. package/dist/{presets-DuXiUNAx.mjs → presets-tEIGoZMO.mjs} +54 -76
  49. package/dist/presets.d.mts +1 -1
  50. package/dist/presets.mjs +1 -1
  51. package/dist/{rolldown-runtime-BhDjJH2R.mjs → rolldown-runtime-D70C1uOS.mjs} +1 -2
  52. package/dist/serializer.cjs +1 -2
  53. package/dist/serializer.d.cts +1 -3
  54. package/dist/serializer.d.mts +1 -3
  55. package/dist/serializer.mjs +1 -2
  56. package/dist/setup.mjs +58 -112
  57. package/dist/{worker-vitest-BGPo0ek6.mjs → worker-vitest-xlSyOBxD.mjs} +2 -3
  58. package/docs/migrating-from-jest.md +7 -0
  59. package/package.json +20 -8
package/README.md CHANGED
@@ -320,6 +320,10 @@ reactNative({
320
320
  });
321
321
  ```
322
322
 
323
+ That object requires the hot runtime and fails where it cannot run. Add `mode: "auto"` to keep
324
+ these options and fall back to per-file isolation instead, as `'auto'` does:
325
+ `hotRuntime: { mode: "auto", memoryLimit: 2 * 1024 ** 3 }`.
326
+
323
327
  Recycling is applied between Vitest scheduler tasks. Current Vitest batches every file into one
324
328
  uninterruptible task at `maxWorkers: 1`, so `'auto'` keeps per-file isolation there and
325
329
  `hotRuntime: true` fails that configuration rather than claim an inert memory bound. Use at least
package/dist/cli.d.mts CHANGED
@@ -1,3 +1 @@
1
- //#region src/cli/index.d.ts
2
- export declare function main(argv: string[], log?: (line: string) => void): number;
3
- //#endregion
1
+ export declare function main(argv: string[], log?: (line: string) => void): number;
package/dist/cli.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { C as validatePeerDependency, _ as fsModuleCacheOnByDefault, b as installedExpoVersion, c as detectEngine, i as ownVitestPackage, l as resolveTransformPreset, o as usesVitePlus, p as formatNativeOwnershipManifest, r as installedViteVersion, s as detectEcosystemPackages, u as createNativeOwnershipPolicy, x as unsupportedExpoSdkMessage, y as PEER_REQUIREMENTS } from "./host-C3wt9zUE.mjs";
3
- import { i as autoDetectedPresetApplies, n as DEFAULT_ASSET_EXTS, o as presetShadowing, r as PRESET_MODULES, s as testsItself, t as AUTO_DETECT_PRESETS } from "./preset-map-L1-vD19T.mjs";
4
- import { n as formatHotMemoryPlan, t as createHotMemoryPlan } from "./memory-BFxB285Z.mjs";
2
+ import { D as validatePeerDependency, S as PEER_REQUIREMENTS, T as unsupportedExpoSdkMessage, b as fsModuleCacheOnByDefault, c as detectEngine, i as ownVitestPackage, l as resolveTransformPreset, o as usesVitePlus, p as formatNativeOwnershipManifest, r as installedViteVersion, s as detectEcosystemPackages, u as createNativeOwnershipPolicy, w as installedExpoVersion } from "./host-CzQ2Jpia.mjs";
3
+ import { i as autoDetectedPresetApplies, n as DEFAULT_ASSET_EXTS, o as presetShadowing, r as PRESET_MODULES, s as testsItself, t as AUTO_DETECT_PRESETS } from "./preset-map-n08Oz-ZL.mjs";
4
+ import { n as formatHotMemoryPlan, t as createHotMemoryPlan } from "./memory-B9IFtT_r.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
- //#region src/native/state-manifest.mjs
8
+ // src/native/state-manifest.mjs
9
9
  const HOT_STATE_MANIFEST_ENTRIES = Object.freeze([
10
10
  "vitest-runtime",
11
11
  "native-boundary-mocks",
@@ -19,10 +19,10 @@ const HOT_STATE_MANIFEST_ENTRIES = Object.freeze([
19
19
  "console.descriptors",
20
20
  "react-native.error-utils",
21
21
  "expo.runtime",
22
- "jest-compat.node-mocks"
22
+ "jest-compat.node-mocks",
23
+ "expo.sdk-warnings"
23
24
  ]);
24
- //#endregion
25
- //#region src/cli/manifest.ts
25
+ // src/cli/manifest.ts
26
26
  /**
27
27
  * Installed-package facts for the CLI, read from disk.
28
28
  *
@@ -72,8 +72,7 @@ function activePresets(root, disabled = [], engine = "native") {
72
72
  }
73
73
  return [...active];
74
74
  }
75
- //#endregion
76
- //#region src/cli/babel-config.ts
75
+ // src/cli/babel-config.ts
77
76
  /**
78
77
  * The project's Babel configuration, as `migrate` and `doctor` need to see it.
79
78
  *
@@ -332,8 +331,7 @@ function serializableOptions(entry) {
332
331
  };
333
332
  return entry.options === void 0 || plain(entry.options);
334
333
  }
335
- //#endregion
336
- //#region src/cli/doctor.ts
334
+ // src/cli/doctor.ts
337
335
  /**
338
336
  * `vitest-native doctor` — diagnose the project's environment: peer versions,
339
337
  * engine resolution (and why), detected presets, RNTL/Node compatibility, and
@@ -706,8 +704,7 @@ function runDoctor(root, nodeVersion = process.versions.node) {
706
704
  ok
707
705
  };
708
706
  }
709
- //#endregion
710
- //#region src/cli/init.ts
707
+ // src/cli/init.ts
711
708
  /**
712
709
  * `vitest-native init` — write a ready-to-run Vitest config. Two shapes:
713
710
  * the zero-config default, and the jest-compat variant (the exact block the
@@ -889,8 +886,7 @@ function tryExpand(source, literalDot) {
889
886
  throw error;
890
887
  }
891
888
  }
892
- //#endregion
893
- //#region src/cli/allowlist.ts
889
+ // src/cli/allowlist.ts
894
890
  /**
895
891
  * Reading Jest's `transformIgnorePatterns` allowlist,
896
892
  * `node_modules/(?!(a|b|@scope/c)/)`. Real ones nest — React Native's own preset
@@ -987,8 +983,7 @@ function allows(entry, pkg) {
987
983
  if (entry.kind === "scope") return pkg.startsWith(`${entry.name}/`);
988
984
  return pkg.startsWith(entry.name);
989
985
  }
990
- //#endregion
991
- //#region src/cli/jest-discovery.ts
986
+ // src/cli/jest-discovery.ts
992
987
  /**
993
988
  * Which files Jest treats as tests, said to Vitest.
994
989
  *
@@ -1351,8 +1346,7 @@ function booleanFlag(value) {
1351
1346
  if (value === true || value === "true") return true;
1352
1347
  if (value === "false") return false;
1353
1348
  }
1354
- //#endregion
1355
- //#region src/cli/untranspiled.ts
1349
+ // src/cli/untranspiled.ts
1356
1350
  /**
1357
1351
  * Evidence that a package needs `transform`: a `.js` file under one of its entry
1358
1352
  * points that is not standard JavaScript (JSX or Flow), which neither Node nor Vite
@@ -1460,8 +1454,7 @@ function untranspiledFile(root, pkg) {
1460
1454
  }
1461
1455
  return null;
1462
1456
  }
1463
- //#endregion
1464
- //#region src/cli/migrate.ts
1457
+ // src/cli/migrate.ts
1465
1458
  /**
1466
1459
  * `vitest-native migrate` — analyze a project's Jest configuration and report,
1467
1460
  * key by key, what maps automatically, what the presets already cover (delete
@@ -1982,8 +1975,7 @@ function renderMigrationReport(report) {
1982
1975
  lines.push(report.vitePlus ? "Re-run with --write to save this config, then: npx vitest-native doctor && vp test" : "Re-run with --write to save this config, then: npx vitest-native doctor && npx vitest", "", ...HOT_RUNTIME_NOTE);
1983
1976
  return lines;
1984
1977
  }
1985
- //#endregion
1986
- //#region src/cli/index.ts
1978
+ // src/cli/index.ts
1987
1979
  /**
1988
1980
  * vitest-native CLI: `init` (write a ready config), `doctor` (diagnose the
1989
1981
  * environment), `migrate` (analyze a Jest config and report the mapping).
@@ -2057,5 +2049,4 @@ function main(argv, log = console.log) {
2057
2049
  }
2058
2050
  const entry = process.argv[1] ? path.basename(process.argv[1]) : "";
2059
2051
  if (entry === "cli.mjs" || entry === "cli.cjs" || entry === "vitest-native") process.exit(main(process.argv.slice(2)));
2060
- //#endregion
2061
2052
  export { main };
@@ -13,6 +13,9 @@ export interface ProjectContextFields {
13
13
  assetExts?: string[];
14
14
  hotPreserveGlobals?: string[];
15
15
  hotEsmGeneration?: boolean;
16
+ /** Coverage is on: Node-compiled project source carries an inline source map. */
17
+ sourceMaps?: boolean;
18
+ hotReleaseGenerations?: boolean;
16
19
  registry?: string;
17
20
  ownership?: Record<string, unknown>;
18
21
  projectDirs?: string[];
@@ -27,6 +30,8 @@ export interface ProjectContextFields {
27
30
  knownNativeModules?: string[];
28
31
  nativeModuleSpecs?: Record<string, string[]>;
29
32
  nativeModules?: "permissive";
33
+ /** The supported Expo SDKs, `[minimum, maximum]` (checkLoadedExpoSdk). */
34
+ expoSdks?: [number, number];
30
35
  }
31
36
 
32
37
  export declare function writeProjectContext(
package/dist/context.mjs CHANGED
@@ -35,6 +35,8 @@ const SCHEMA = {
35
35
  assetExts: { valid: strings },
36
36
  hotPreserveGlobals: { valid: strings },
37
37
  hotEsmGeneration: { valid: (v) => typeof v === "boolean" },
38
+ sourceMaps: { valid: (v) => typeof v === "boolean" },
39
+ hotReleaseGenerations: { valid: (v) => typeof v === "boolean" },
38
40
  registry: { valid: absolute },
39
41
  ownership: { valid: object },
40
42
  projectDirs: { valid: strings },
@@ -52,6 +54,9 @@ const SCHEMA = {
52
54
  knownNativeModules: { valid: strings },
53
55
  nativeModuleSpecs: { valid: object },
54
56
  nativeModules: { valid: (v) => v === "permissive" },
57
+ expoSdks: {
58
+ valid: (v) => Array.isArray(v) && v.length === 2 && v.every((n) => Number.isInteger(n)),
59
+ },
55
60
  };
56
61
 
57
62
  function invalid(reason, field, detail, dir) {
@@ -1,4 +1,4 @@
1
- //#region src/errors.mjs
1
+ // src/errors.mjs
2
2
  /**
3
3
  * The error types this package throws.
4
4
  *
@@ -60,5 +60,4 @@ var VitestNativeTypeError = class extends TypeError {
60
60
  this.code = code;
61
61
  }
62
62
  };
63
- //#endregion
64
63
  export { VitestNativeTypeError as n, VitestNativeError as t };
package/dist/errors.d.mts CHANGED
@@ -42,6 +42,7 @@ export type VitestNativeErrorCode =
42
42
  | "JEST_MOCK_FACTORY_CYCLE"
43
43
  | "JEST_COMPAT_SETUP_MISSING"
44
44
  | "BABEL_IGNORES_FILE"
45
+ | "IMPORT_META_IN_NODE_OWNED"
45
46
  | "MATCHER_BAD_RECEIVER";
46
47
 
47
48
  export interface VitestNativeErrorOptions {
package/dist/helpers.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/errors.mjs
2
+ // src/errors.mjs
3
3
  /**
4
4
  * The error types this package throws.
5
5
  *
@@ -50,8 +50,7 @@ var VitestNativeError = class extends Error {
50
50
  this.code = code;
51
51
  }
52
52
  };
53
- //#endregion
54
- //#region src/helpers.ts
53
+ // src/helpers.ts
55
54
  /**
56
55
  * Test helpers for vitest-native.
57
56
  *
@@ -202,7 +201,6 @@ function resetAllMocks() {
202
201
  }
203
202
  }
204
203
  }
205
- //#endregion
206
204
  exports.extendPresetMock = extendPresetMock;
207
205
  exports.mockNativeModule = mockNativeModule;
208
206
  exports.resetAllMocks = resetAllMocks;
@@ -1,4 +1,3 @@
1
- //#region src/helpers.d.ts
2
1
  export declare function setPlatform(os: "ios" | "android"): void;
3
2
  export declare function setDimensions(dims: {
4
3
  width: number;
@@ -21,5 +20,4 @@ export declare function setInsets(insets: {
21
20
  */
22
21
  export declare function extendPresetMock(pkg: string, overrides: Record<string, any>): boolean;
23
22
  export declare function mockNativeModule(name: string, impl: Record<string, any>): void;
24
- export declare function resetAllMocks(): void;
25
- //#endregion
23
+ export declare function resetAllMocks(): void;
@@ -1,4 +1,3 @@
1
- //#region src/helpers.d.ts
2
1
  export declare function setPlatform(os: "ios" | "android"): void;
3
2
  export declare function setDimensions(dims: {
4
3
  width: number;
@@ -21,5 +20,4 @@ export declare function setInsets(insets: {
21
20
  */
22
21
  export declare function extendPresetMock(pkg: string, overrides: Record<string, any>): boolean;
23
22
  export declare function mockNativeModule(name: string, impl: Record<string, any>): void;
24
- export declare function resetAllMocks(): void;
25
- //#endregion
23
+ export declare function resetAllMocks(): void;
package/dist/helpers.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as VitestNativeError } from "./errors-CxoBUfVJ.mjs";
2
- //#region src/helpers.ts
1
+ import { t as VitestNativeError } from "./errors-ijs8WAcX.mjs";
2
+ // src/helpers.ts
3
3
  /**
4
4
  * Test helpers for vitest-native.
5
5
  *
@@ -150,5 +150,4 @@ function resetAllMocks() {
150
150
  }
151
151
  }
152
152
  }
153
- //#endregion
154
153
  export { extendPresetMock, mockNativeModule, resetAllMocks, setColorScheme, setDimensions, setInsets, setPlatform };