vitest-native 0.13.0 → 0.14.0-rc.2
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.
- package/CHANGELOG.md +339 -0
- package/README.md +138 -48
- package/dist/cli.cjs +70 -5
- package/dist/cli.d.cts +2 -3
- package/dist/cli.d.mts +2 -3
- package/dist/cli.mjs +70 -5
- package/dist/{ecosystem-Duw40-mO.mjs → ecosystem-DFbU_MPe.mjs} +389 -18
- package/dist/{ecosystem-CEIF_-jq.cjs → ecosystem-DI1AhK_k.cjs} +408 -25
- package/dist/errors.d.mts +12 -0
- package/dist/helpers.cjs +6 -3
- package/dist/helpers.d.cts +8 -9
- package/dist/helpers.d.mts +8 -9
- package/dist/helpers.mjs +6 -3
- package/dist/{index-CPGq6p95.d.cts → index-BxzW2D7K.d.cts} +33 -9
- package/dist/{index-CmETArCM.d.mts → index-CEbwa4QU.d.mts} +33 -9
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +537 -118
- package/dist/jest-compat/aliases.d.mts +5 -0
- package/dist/jest-compat/aliases.mjs +65 -0
- package/dist/jest-compat/caller.mjs +53 -0
- package/dist/jest-compat/setup.mjs +72 -36
- package/dist/jest-compat.cjs +1 -3
- package/dist/jest-compat.d.cts +4 -5
- package/dist/jest-compat.d.mts +4 -5
- package/dist/jest-compat.mjs +1 -1
- package/dist/matchers.d.cts +9 -9
- package/dist/matchers.d.mts +9 -9
- package/dist/memory-6EPHrJA1.cjs +144 -0
- package/dist/memory-FYbP0_gg.mjs +126 -0
- package/dist/native/boundary.mjs +13 -2
- package/dist/native/bounded-process.mjs +165 -0
- package/dist/native/export-condition-recovery-preload.mjs +5 -0
- package/dist/native/export-condition-recovery.mjs +195 -0
- package/dist/native/globals.mjs +133 -5
- package/dist/native/hooks.mjs +131 -71
- package/dist/native/loader.mjs +41 -28
- package/dist/native/match.d.mts +3 -0
- package/dist/native/match.mjs +38 -2
- package/dist/native/metro-profile-compiler.mjs +234 -0
- package/dist/native/metro-profile.mjs +115 -0
- package/dist/native/module-reset.mjs +111 -6
- package/dist/native/ownership.d.mts +105 -0
- package/dist/native/ownership.mjs +474 -0
- package/dist/native/registry-compiler.mjs +43 -0
- package/dist/native/registry-process.mjs +124 -0
- package/dist/native/registry.mjs +139 -32
- package/dist/native/reset.mjs +305 -135
- package/dist/native/resolve.d.mts +20 -3
- package/dist/native/resolve.mjs +32 -12
- package/dist/native/rntl-hooks.mjs +76 -0
- package/dist/native/setup.mjs +81 -32
- package/dist/native/state-manifest.d.mts +22 -0
- package/dist/native/state-manifest.mjs +136 -0
- package/dist/native/transform.mjs +29 -8
- package/dist/native/worker.mjs +52 -4
- package/dist/pool-B4yesGhI.cjs +121 -0
- package/dist/pool-DjpOjOf3.mjs +119 -0
- package/dist/{presets-CoNf4ByH.cjs → presets-BYHmi7-W.cjs} +117 -18
- package/dist/{presets-DGProTaA.mjs → presets-DC-eM5IA.mjs} +117 -18
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rntl-matchers.d.ts +58 -12
- package/dist/serializer.cjs +4 -2
- package/dist/serializer.d.cts +3 -4
- package/dist/serializer.d.mts +3 -4
- package/dist/serializer.mjs +4 -2
- package/dist/setup.mjs +61 -50
- package/dist/worker-vitest-BGPo0ek6.mjs +49 -0
- package/dist/worker-vitest-BfiQB8ND.cjs +62 -0
- package/docs/hot-default-design.md +175 -88
- package/docs/migrating-from-jest.md +12 -5
- package/docs/migrating-from-vitest-react-native.md +4 -4
- package/docs/release-readiness.md +39 -13
- package/docs/versioning.md +19 -18
- package/package.json +42 -31
- package/dist/pool-BU-1ecIF.cjs +0 -122
- package/dist/pool-Bcxn9a3I.mjs +0 -118
package/dist/helpers.mjs
CHANGED
|
@@ -148,9 +148,12 @@ function resetAllMocks() {
|
|
|
148
148
|
originalNativeModules = null;
|
|
149
149
|
}
|
|
150
150
|
const presetMocks = globalThis.__vitest_native_preset_mocks;
|
|
151
|
-
if (presetMocks)
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
if (presetMocks) {
|
|
152
|
+
const built = presetMocks[Symbol.for("vitest-native.presets-built")];
|
|
153
|
+
for (const mod of built ? [...built.values()] : Object.values(presetMocks)) {
|
|
154
|
+
if (mod?._reset) mod._reset();
|
|
155
|
+
if (mod?._resetStore) mod._resetStore();
|
|
156
|
+
}
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
//#endregion
|
|
@@ -279,6 +279,19 @@ interface VitestNativeOptions {
|
|
|
279
279
|
diagnostics?: boolean;
|
|
280
280
|
/** Additional asset file extensions to stub (e.g. ['.lottie', '.m4b']) */
|
|
281
281
|
assetExts?: string[];
|
|
282
|
+
/**
|
|
283
|
+
* Experimental. Read the project's declarative Metro resolution profile in a
|
|
284
|
+
* short-lived, memory-bounded child. Default: false (built-in React Native
|
|
285
|
+
* extension/asset defaults). Pass true or an options object to opt in.
|
|
286
|
+
*
|
|
287
|
+
* Imperative `resolver.resolveRequest` behavior cannot be transferred as data:
|
|
288
|
+
* when the config installs one, the source and asset extensions still apply and
|
|
289
|
+
* a warning names the gap. Main fields and conditions are reported under
|
|
290
|
+
* diagnostics but retain the engine's ownership policy.
|
|
291
|
+
*/
|
|
292
|
+
metroConfig?: boolean | {
|
|
293
|
+
configFile?: string;
|
|
294
|
+
};
|
|
282
295
|
/**
|
|
283
296
|
* `engine: 'native'` only. Names of additional node_modules packages whose
|
|
284
297
|
* source the native engine should transform (Flow/TS/JSX stripped) as it
|
|
@@ -319,7 +332,8 @@ interface VitestNativeOptions {
|
|
|
319
332
|
exclude?: string[];
|
|
320
333
|
};
|
|
321
334
|
/**
|
|
322
|
-
* `engine: 'native'` only.
|
|
335
|
+
* `engine: 'native'` only. Built on Vitest's experimental custom-pool API.
|
|
336
|
+
* Run tests in persistent
|
|
323
337
|
* RN-hot workers: React Native's module graph loads once per worker and
|
|
324
338
|
* stays resident across test files, while each file still gets a fresh
|
|
325
339
|
* Vitest module runner (per-file isolation of your app/test modules).
|
|
@@ -331,12 +345,14 @@ interface VitestNativeOptions {
|
|
|
331
345
|
* is enforced between Vitest scheduler tasks; a single task containing
|
|
332
346
|
* multiple files cannot be interrupted.
|
|
333
347
|
* - `memoryLimit`: retire a worker when its reported JS heap (bytes) meets
|
|
334
|
-
* or exceeds this value, also between scheduler tasks.
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
348
|
+
* or exceeds this value, also between scheduler tasks. By default a
|
|
349
|
+
* constrained-memory-aware plan derives this threshold, caps automatic
|
|
350
|
+
* concurrency at four, reserves main-process and worker-replacement RSS,
|
|
351
|
+
* and stops before crossing 90% of the host/container limit.
|
|
352
|
+
* - `allowUnboundedMemory`: explicitly permit configurations where Vitest
|
|
353
|
+
* cannot enforce file-boundary recycling, notably `maxWorkers: 1`. This
|
|
354
|
+
* also disables the automatic worker cap and process-RSS hard stop. Use
|
|
355
|
+
* only when an external scheduler provides the memory boundary.
|
|
340
356
|
* - `preserveGlobals`: exact globalThis property names intentionally owned
|
|
341
357
|
* by resident external libraries. App/test globals are otherwise removed
|
|
342
358
|
* between files. Storybook's preview registry is preserved automatically.
|
|
@@ -350,11 +366,19 @@ interface VitestNativeOptions {
|
|
|
350
366
|
* stock isolation, against 13.9x with it off. Set false to trade that back,
|
|
351
367
|
* accepting that a package holding state across files will keep it.
|
|
352
368
|
*
|
|
353
|
-
*
|
|
369
|
+
* `'auto'` selects the bounded hot runtime when the configuration has recyclable
|
|
370
|
+
* task boundaries (enough memory headroom for at least two workers) and no
|
|
371
|
+
* explicit custom pool; otherwise the run keeps per-file isolation. Set
|
|
372
|
+
* explicitly, it prints the reason for falling back; as the default it falls
|
|
373
|
+
* back quietly (`diagnostics: true` shows the reason).
|
|
374
|
+
*
|
|
375
|
+
* Default: `'auto'`. `false` always runs each file in a fresh worker, with React
|
|
376
|
+
* Native reloaded per file.
|
|
354
377
|
*/
|
|
355
|
-
hotRuntime?: boolean | {
|
|
378
|
+
hotRuntime?: boolean | "auto" | {
|
|
356
379
|
recycleAfterFiles?: number;
|
|
357
380
|
memoryLimit?: number;
|
|
381
|
+
allowUnboundedMemory?: boolean;
|
|
358
382
|
preserveGlobals?: string[];
|
|
359
383
|
esmGeneration?: boolean;
|
|
360
384
|
};
|
|
@@ -278,6 +278,19 @@ interface VitestNativeOptions {
|
|
|
278
278
|
diagnostics?: boolean;
|
|
279
279
|
/** Additional asset file extensions to stub (e.g. ['.lottie', '.m4b']) */
|
|
280
280
|
assetExts?: string[];
|
|
281
|
+
/**
|
|
282
|
+
* Experimental. Read the project's declarative Metro resolution profile in a
|
|
283
|
+
* short-lived, memory-bounded child. Default: false (built-in React Native
|
|
284
|
+
* extension/asset defaults). Pass true or an options object to opt in.
|
|
285
|
+
*
|
|
286
|
+
* Imperative `resolver.resolveRequest` behavior cannot be transferred as data:
|
|
287
|
+
* when the config installs one, the source and asset extensions still apply and
|
|
288
|
+
* a warning names the gap. Main fields and conditions are reported under
|
|
289
|
+
* diagnostics but retain the engine's ownership policy.
|
|
290
|
+
*/
|
|
291
|
+
metroConfig?: boolean | {
|
|
292
|
+
configFile?: string;
|
|
293
|
+
};
|
|
281
294
|
/**
|
|
282
295
|
* `engine: 'native'` only. Names of additional node_modules packages whose
|
|
283
296
|
* source the native engine should transform (Flow/TS/JSX stripped) as it
|
|
@@ -318,7 +331,8 @@ interface VitestNativeOptions {
|
|
|
318
331
|
exclude?: string[];
|
|
319
332
|
};
|
|
320
333
|
/**
|
|
321
|
-
* `engine: 'native'` only.
|
|
334
|
+
* `engine: 'native'` only. Built on Vitest's experimental custom-pool API.
|
|
335
|
+
* Run tests in persistent
|
|
322
336
|
* RN-hot workers: React Native's module graph loads once per worker and
|
|
323
337
|
* stays resident across test files, while each file still gets a fresh
|
|
324
338
|
* Vitest module runner (per-file isolation of your app/test modules).
|
|
@@ -330,12 +344,14 @@ interface VitestNativeOptions {
|
|
|
330
344
|
* is enforced between Vitest scheduler tasks; a single task containing
|
|
331
345
|
* multiple files cannot be interrupted.
|
|
332
346
|
* - `memoryLimit`: retire a worker when its reported JS heap (bytes) meets
|
|
333
|
-
* or exceeds this value, also between scheduler tasks.
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
347
|
+
* or exceeds this value, also between scheduler tasks. By default a
|
|
348
|
+
* constrained-memory-aware plan derives this threshold, caps automatic
|
|
349
|
+
* concurrency at four, reserves main-process and worker-replacement RSS,
|
|
350
|
+
* and stops before crossing 90% of the host/container limit.
|
|
351
|
+
* - `allowUnboundedMemory`: explicitly permit configurations where Vitest
|
|
352
|
+
* cannot enforce file-boundary recycling, notably `maxWorkers: 1`. This
|
|
353
|
+
* also disables the automatic worker cap and process-RSS hard stop. Use
|
|
354
|
+
* only when an external scheduler provides the memory boundary.
|
|
339
355
|
* - `preserveGlobals`: exact globalThis property names intentionally owned
|
|
340
356
|
* by resident external libraries. App/test globals are otherwise removed
|
|
341
357
|
* between files. Storybook's preview registry is preserved automatically.
|
|
@@ -349,11 +365,19 @@ interface VitestNativeOptions {
|
|
|
349
365
|
* stock isolation, against 13.9x with it off. Set false to trade that back,
|
|
350
366
|
* accepting that a package holding state across files will keep it.
|
|
351
367
|
*
|
|
352
|
-
*
|
|
368
|
+
* `'auto'` selects the bounded hot runtime when the configuration has recyclable
|
|
369
|
+
* task boundaries (enough memory headroom for at least two workers) and no
|
|
370
|
+
* explicit custom pool; otherwise the run keeps per-file isolation. Set
|
|
371
|
+
* explicitly, it prints the reason for falling back; as the default it falls
|
|
372
|
+
* back quietly (`diagnostics: true` shows the reason).
|
|
373
|
+
*
|
|
374
|
+
* Default: `'auto'`. `false` always runs each file in a fresh worker, with React
|
|
375
|
+
* Native reloaded per file.
|
|
353
376
|
*/
|
|
354
|
-
hotRuntime?: boolean | {
|
|
377
|
+
hotRuntime?: boolean | "auto" | {
|
|
355
378
|
recycleAfterFiles?: number;
|
|
356
379
|
memoryLimit?: number;
|
|
380
|
+
allowUnboundedMemory?: boolean;
|
|
357
381
|
preserveGlobals?: string[];
|
|
358
382
|
esmGeneration?: boolean;
|
|
359
383
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as ReactNativeMock, t as index_d_exports, x as VitestNativeOptions, y as Preset } from "./index-
|
|
1
|
+
import { b as ReactNativeMock, t as index_d_exports, x as VitestNativeOptions, y as Preset } from "./index-CEbwa4QU.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ import { Plugin } from "vite";
|
|
|
9
9
|
* list that silently rots as dependencies change. The object form keeps detection
|
|
10
10
|
* and names only what to drop.
|
|
11
11
|
*/
|
|
12
|
-
declare function disabledPresetNames(presets: unknown): Set<string>;
|
|
13
|
-
declare function reactNative(options?: VitestNativeOptions): Plugin;
|
|
12
|
+
export declare function disabledPresetNames(presets: unknown): Set<string>;
|
|
13
|
+
export declare function reactNative(options?: VitestNativeOptions): Plugin;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { type Preset, type ReactNativeMock, type VitestNativeOptions,
|
|
15
|
+
export { type Preset, type ReactNativeMock, type VitestNativeOptions, index_d_exports as presets };
|