vitest-native 0.15.1 → 0.16.0-rc.1
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/dist/cli.mjs +9 -5
- package/dist/context.d.mts +6 -0
- package/dist/context.mjs +5 -0
- package/dist/errors.d.mts +3 -0
- package/dist/{host-BY3RaLPW.mjs → host-X6VHF-a4.mjs} +455 -14
- package/dist/{index-DQz6guT5.d.mts → index-X3wuvaqa.d.mts} +8 -10
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +134 -39
- package/dist/jest-compat/jest-object.mjs +62 -17
- package/dist/jest-compat/node-registry.mjs +496 -126
- package/dist/jest-compat/setup.mjs +32 -4
- package/dist/jest-compat.cjs +91 -19
- package/dist/jest-compat.d.cts +1 -1
- package/dist/jest-compat.d.mts +1 -1
- package/dist/jest-compat.mjs +91 -19
- package/dist/native/assets.mjs +41 -10
- package/dist/native/babel-worker.mjs +4 -2
- package/dist/native/boundary.mjs +17 -13
- package/dist/native/explain.mjs +101 -5
- package/dist/native/expo-module-mocks.mjs +3 -0
- package/dist/native/hooks.mjs +8 -2
- package/dist/native/library-jest.mjs +16 -8
- package/dist/native/loader.mjs +51 -1
- package/dist/native/ownership-ledger.d.mts +2 -0
- package/dist/native/ownership-ledger.mjs +3 -2
- package/dist/native/react-dedupe.d.mts +7 -0
- package/dist/native/react-dedupe.mjs +191 -0
- package/dist/native/registry-process.mjs +88 -12
- package/dist/native/registry.mjs +3 -3
- package/dist/native/resolve.mjs +5 -1
- package/dist/native/setup.mjs +0 -5
- package/dist/native/transform.mjs +3 -2
- package/dist/native/worker.mjs +0 -8
- package/dist/node-dispatch.mjs +2 -0
- package/dist/preset-react.mjs +20 -3
- package/dist/{presets-cQiD0YHw.mjs → presets-Dw0Sz9O6.mjs} +505 -36
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/setup.mjs +1 -1
- package/package.json +5 -2
- package/dist/memory-Couw0Esx.mjs +0 -151
- package/dist/native/compile-cache.mjs +0 -57
package/dist/cli.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as unsupportedNodeMessage, B as unsupportedReactNativeMessage, C as installedManifest, D as SUPPORTED_NODE, I as belowRecommendedMessage, L as installedExpoVersion, M as validatePeerDependency, P as PEER_REQUIREMENTS, R as isBelowSupportedReactNative, S as normalizeBabelName, b as classifyBabelPlugins, c as formatHotMemoryPlan, f as detectEcosystemPackages, h as detectEngine, i as ownVitestPackage, k as satisfiesNodeRange, m as isPlainJavaScript, o as usesVitePlus, p as babelParser, r as installedViteVersion, s as createHotMemoryPlan, v as missingBabelCoreNotice, x as isKnownPlugin, y as projectBabelTrigger, z as unsupportedExpoSdkMessage } from "./host-X6VHF-a4.mjs";
|
|
3
3
|
import { a as PRESET_MODULES, f as presetShadowing, i as LIBRARY_SETUP_FILES, l as libraryMockUsable, m as testsItself, r as DEFAULT_ASSET_EXTS, s as autoDetectedPresetApplies, t as AUTO_DETECT_PRESETS } from "./preset-map-DdAexIwz.mjs";
|
|
4
4
|
import { n as ignorePattern, t as findNodeModuleMocks } from "./root-mocks-DP95ncxD.mjs";
|
|
5
|
-
import { n as formatHotMemoryPlan, t as createHotMemoryPlan } from "./memory-Couw0Esx.mjs";
|
|
6
5
|
import { createRequire } from "node:module";
|
|
7
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
7
|
import path from "node:path";
|
|
@@ -11,11 +10,12 @@ import os from "node:os";
|
|
|
11
10
|
import { VitestNativeError } from "./errors.mjs";
|
|
12
11
|
import { docsUrl } from "./docs-url.mjs";
|
|
13
12
|
import { createNativeOwnershipPolicy, formatNativeOwnershipManifest } from "./native/ownership.mjs";
|
|
13
|
+
import { REACT_DEDUPE } from "./native/react-dedupe.mjs";
|
|
14
14
|
import { relativeToRoot, rootSpellings } from "./native/root-spelling.mjs";
|
|
15
15
|
import { resolveTransformPreset } from "./native/babel-preset.mjs";
|
|
16
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
16
17
|
import { HOT_STATE_MANIFEST_ENTRIES } from "./native/state-manifest.mjs";
|
|
17
18
|
import { isDeepStrictEqual } from "node:util";
|
|
18
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
19
19
|
import { StringDecoder } from "node:string_decoder";
|
|
20
20
|
// src/cli/manifest.ts
|
|
21
21
|
/**
|
|
@@ -718,6 +718,8 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
718
718
|
* the zero-config default, and the jest-compat variant (the exact block the
|
|
719
719
|
* migration guide documents, so docs and CLI can never drift apart by shape).
|
|
720
720
|
*/
|
|
721
|
+
/** The engine's own dedupe list, as config source. */
|
|
722
|
+
const DEDUPE_SOURCE$1 = REACT_DEDUPE.map((name) => `'${name}'`).join(", ");
|
|
721
723
|
/**
|
|
722
724
|
* Printed after `init` and `migrate`: the hot runtime is off by default, so a user
|
|
723
725
|
* reading only the CLI output would not otherwise learn it exists or what it costs.
|
|
@@ -751,7 +753,7 @@ export default defineConfig({
|
|
|
751
753
|
// Vitest's own mock hoister. Its position relative to reactNative() does not matter.
|
|
752
754
|
plugins: [reactNative(), jestMockTransform()],
|
|
753
755
|
resolve: {
|
|
754
|
-
dedupe: [
|
|
756
|
+
dedupe: [${DEDUPE_SOURCE$1}],
|
|
755
757
|
alias: { ...jestCompatAliases() },
|
|
756
758
|
},
|
|
757
759
|
test: {
|
|
@@ -1936,6 +1938,8 @@ function untranspiledFile(root, pkg) {
|
|
|
1936
1938
|
* so that a migrated project collects the same test files with the same settings
|
|
1937
1939
|
* without hand edits.
|
|
1938
1940
|
*/
|
|
1941
|
+
/** The engine's own dedupe list, as config source. */
|
|
1942
|
+
const DEDUPE_SOURCE = REACT_DEDUPE.map((name) => `'${name}'`).join(", ");
|
|
1939
1943
|
/**
|
|
1940
1944
|
* Jest 30's lookup order for `jest.config.*` (jest-config's JEST_CONFIG_EXT_ORDER; Jest 29's is
|
|
1941
1945
|
* the same without .mts and .cts). Jest refuses to run when more than one exists, so the order
|
|
@@ -2574,7 +2578,7 @@ export default defineConfig({
|
|
|
2574
2578
|
transformCall
|
|
2575
2579
|
].join(", ")}],
|
|
2576
2580
|
resolve: {
|
|
2577
|
-
dedupe: [
|
|
2581
|
+
dedupe: [${DEDUPE_SOURCE}],
|
|
2578
2582
|
alias: ${aliasSource},
|
|
2579
2583
|
},
|
|
2580
2584
|
test: {
|
package/dist/context.d.mts
CHANGED
|
@@ -27,6 +27,12 @@ export interface ProjectContextFields {
|
|
|
27
27
|
packageDirs?: { root: string; dirs: Record<string, string | null> };
|
|
28
28
|
ownershipGuard?: { mode: "warn" | "error"; allow: { path: string; reason: string }[] };
|
|
29
29
|
projectDirs?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* `[dir, name, parent]` for each installed dependency of a package found only by the
|
|
32
|
+
* installed scan that is not compiled: Node fails a file of one by name when it cannot
|
|
33
|
+
* run as published (#883).
|
|
34
|
+
*/
|
|
35
|
+
scanFoundDependencies?: [string, string, string][];
|
|
30
36
|
requireAliases?: [string, string][];
|
|
31
37
|
/** The project sets test.restoreMocks: jest-compat restores jest.replaceProperty() before each test. */
|
|
32
38
|
restoreMocks?: true;
|
package/dist/context.mjs
CHANGED
|
@@ -52,6 +52,11 @@ const SCHEMA = {
|
|
|
52
52
|
},
|
|
53
53
|
ownershipGuard: { valid: object },
|
|
54
54
|
projectDirs: { valid: strings },
|
|
55
|
+
scanFoundDependencies: {
|
|
56
|
+
valid: (v) =>
|
|
57
|
+
Array.isArray(v) &&
|
|
58
|
+
v.every((e) => Array.isArray(e) && e.length === 3 && strings(e) && absolute(e[0])),
|
|
59
|
+
},
|
|
55
60
|
requireAliases: {
|
|
56
61
|
valid: (v) =>
|
|
57
62
|
Array.isArray(v) && v.every((e) => Array.isArray(e) && e.length === 2 && strings(e)),
|
package/dist/errors.d.mts
CHANGED
|
@@ -35,6 +35,7 @@ export type VitestNativeErrorCode =
|
|
|
35
35
|
| "METRO_PROFILE_INVALID"
|
|
36
36
|
| "TRANSFORM_FAILED"
|
|
37
37
|
| "UNTRANSPILED_PACKAGE"
|
|
38
|
+
| "UNDECLARED_DEPENDENCY_UNCOMPILED"
|
|
38
39
|
| "HOT_WORKER_ENV"
|
|
39
40
|
| "HOT_WORKER_PRELOAD"
|
|
40
41
|
| "HOT_RUNTIME_UNAVAILABLE"
|
|
@@ -57,8 +58,10 @@ export type VitestNativeErrorCode =
|
|
|
57
58
|
| "JEST_API_UNSUPPORTED"
|
|
58
59
|
| "REQUIRE_ACTUAL_ALIAS_UNSUPPORTED"
|
|
59
60
|
| "JEST_MOCK_FACTORY_CYCLE"
|
|
61
|
+
| "JEST_MOCK_MISSING_EXPORT"
|
|
60
62
|
| "JEST_COMPAT_SETUP_MISSING"
|
|
61
63
|
| "JEST_BINDING_NOT_FOLLOWED"
|
|
64
|
+
| "JEST_MOCK_VI_UNAVAILABLE"
|
|
62
65
|
| "BABEL_IGNORES_FILE"
|
|
63
66
|
| "LIBRARY_REGISTRY_FAILED"
|
|
64
67
|
| "UNKNOWN_DISPATCH_STEP"
|