vitest-native 0.5.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # vitest-native
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 40a5147: Native engine: fix `import { Appearance } from 'react-native'` (and other lazy-getter RN exports) failing with "does not provide an export named …" when the import comes from an **externalized ESM dependency**.
8
+
9
+ React Native's index exposes everything via lazy getters (`module.exports = { get Appearance() {…} }`), which `cjs-module-lexer` can't surface as named exports when Node imports the CommonJS module from the ESM graph. The Node ESM loader now serves RN's main index as a thin re-export of the real (Flow-stripped) module plus a `cjs-module-lexer`-recognized export hint, so named imports resolve while the real getters stay lazy (no eager load of RN's surface). The `require('react-native')` path is unchanged.
10
+
11
+ Previously this needed a manual `transform: ['the-lib']` workaround (e.g. for `uniwind`); that's no longer required. Surfaced by the obytes-template bake-off.
12
+
13
+ ## 0.6.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 3297e5b: Add a built-in `vectorIcons` preset for `@react-native-vector-icons` (v10+),
18
+ auto-detected like the other third-party presets.
19
+
20
+ The library's v10 icon sets (`@react-native-vector-icons/material-icons`, …) are
21
+ all built on the shared `@react-native-vector-icons/common` module, whose dynamic
22
+ font loader runs at import time and queries the native `ExpoFontLoader` — which
23
+ cannot exist in Node. Without shadowing, importing any icon set throws and the set
24
+ is wrongly reported "not available", so icons render nothing. The preset shadows
25
+ the single `common` module (the way jest mocks vector-icons) so `createIconSet(...)`
26
+ returns a lightweight Text-based stub that forwards `name`/`size`/`color`/`style`/
27
+ `testID` — fixing every icon set at once. The legacy `react-native-vector-icons`
28
+ package is mapped to the same preset.
29
+
30
+ Surfaced by the `@rneui/base` bake-off, where every `Icon` test failure traced to
31
+ this import-time crash.
32
+
33
+ ### Patch Changes
34
+
35
+ - e333954: Fix two `Animated` mock fidelity gaps surfaced by the mock-vs-real-RN cross-check:
36
+
37
+ - `Animated.Text` (and the other `Animated.*` components) now render the base host
38
+ component (`Text`, `View`, …) instead of a host literally named `Animated.Text`,
39
+ so RNTL's `getByText`/`queryByText` can find their text children — matching real
40
+ React Native.
41
+ - An `Animated.Value` (or interpolation/color node) used in a `style` prop now
42
+ resolves to its current value on the host's style, so assertions like
43
+ `toHaveStyle({ opacity: 0.3 })` against `new Animated.Value(0.3)` pass — matching
44
+ how real React Native writes the live value onto the host.
45
+
46
+ - Restore Vitest 4.0.x compatibility in the hot-runtime runner. 0.5.0 imported `TestRunner` from the `vitest` main entry, which only exists in 4.1+; on 4.0.x the hot runner threw `Class extends value undefined`. It now prefers the main-entry export and falls back to the (deprecated) `vitest/runners` subpath only when the main export is absent — so 4.1+ stays warning-free and 4.0.x works again.
47
+ - 3297e5b: Native engine: stub asset `require()`s reaching Node's CJS loader. A literal
48
+ `const img = require('./logo.png')` or `require('./Icon.ttf')` (common in real RN
49
+ components) escapes Vite's asset handling and hits Node's loader, where the binary
50
+ was compiled as JS and threw `SyntaxError: Invalid or unexpected token`, taking
51
+ down the whole test file. The Node require-hook now stubs asset extensions
52
+ (images, media, and fonts) to their basename string, matching the Vite graph and
53
+ Metro/Jest behaviour.
54
+
55
+ Surfaced by a real bake-off of the `@rneui/base` (react-native-elements) Jest +
56
+ RNTL suite under the native engine.
57
+
3
58
  ## 0.5.0
4
59
 
5
60
  ### Native engine
@@ -64,7 +119,7 @@ Documentation fixes (the README is consumers' primary reference):
64
119
  note on the `globals: true` alternative.
65
120
  - **Installation** notes the companion dependencies the examples need
66
121
  (`@testing-library/react-native`; a real RN app already provides `react-native`
67
- + `@react-native/babel-preset` + `@babel/core`).
122
+ - `@react-native/babel-preset` + `@babel/core`).
68
123
  - Corrected the RN-conformance count (118 ported: 115 passing, 3 documented skips).
69
124
  - "Spiritual successor" → "Maintained successor" wording, with a migration link.
70
125
 
@@ -1,7 +1,5 @@
1
1
  import { Mock } from "vitest";
2
2
 
3
- //#region \0rolldown/runtime.js
4
- //#endregion
5
3
  //#region src/types.d.ts
6
4
  /** Static methods available on the Image component mock. */
7
5
  interface ImageStatic {
@@ -323,8 +321,11 @@ declare function svg(): Preset;
323
321
  //#endregion
324
322
  //#region src/presets/webview.d.ts
325
323
  declare function webview(): Preset;
324
+ //#endregion
325
+ //#region src/presets/vector-icons.d.ts
326
+ declare function vectorIcons(): Preset;
326
327
  declare namespace index_d_exports {
327
- export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, webview };
328
+ export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
328
329
  }
329
330
  //#endregion
330
- export { deviceInfo as a, asyncStorage as c, gestureHandler as d, reanimated as f, VitestNativeOptions as h, mmkv as i, navigation as l, ReactNativeMock as m, webview as n, expo as o, Preset as p, svg as r, screens as s, index_d_exports as t, safeAreaContext as u };
331
+ export { mmkv as a, screens as c, safeAreaContext as d, gestureHandler as f, VitestNativeOptions as g, ReactNativeMock as h, svg as i, asyncStorage as l, Preset as m, vectorIcons as n, deviceInfo as o, reanimated as p, webview as r, expo as s, index_d_exports as t, navigation as u };
@@ -1,5 +1,7 @@
1
1
  import { Mock } from "vitest";
2
2
 
3
+ //#region \0rolldown/runtime.js
4
+ //#endregion
3
5
  //#region src/types.d.ts
4
6
  /** Static methods available on the Image component mock. */
5
7
  interface ImageStatic {
@@ -321,8 +323,11 @@ declare function svg(): Preset;
321
323
  //#endregion
322
324
  //#region src/presets/webview.d.ts
323
325
  declare function webview(): Preset;
326
+ //#endregion
327
+ //#region src/presets/vector-icons.d.ts
328
+ declare function vectorIcons(): Preset;
324
329
  declare namespace index_d_exports {
325
- export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, webview };
330
+ export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
326
331
  }
327
332
  //#endregion
328
- export { deviceInfo as a, asyncStorage as c, gestureHandler as d, reanimated as f, VitestNativeOptions as h, mmkv as i, navigation as l, ReactNativeMock as m, webview as n, expo as o, Preset as p, svg as r, screens as s, index_d_exports as t, safeAreaContext as u };
333
+ export { mmkv as a, screens as c, safeAreaContext as d, gestureHandler as f, VitestNativeOptions as g, ReactNativeMock as h, svg as i, asyncStorage as l, Preset as m, vectorIcons as n, deviceInfo as o, reanimated as p, webview as r, expo as s, index_d_exports as t, navigation as u };
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-CZWwpsFl.cjs");
3
- const require_preset_map = require("./preset-map-C3jxnkiX.cjs");
4
- const require_presets = require("./presets-E0yIUMJP.cjs");
3
+ const require_preset_map = require("./preset-map-CNBOeqAu.cjs");
4
+ const require_presets = require("./presets-BPVVlfI2.cjs");
5
5
  let node_url = require("node:url");
6
6
  let node_path = require("node:path");
7
7
  node_path = require_chunk.__toESM(node_path, 1);
@@ -475,6 +475,7 @@ function reactNative(options) {
475
475
  };
476
476
  const reactNativeVersion = resolvePackageVersion("react-native", resolvedRoot);
477
477
  if (reactNativeVersion) env.VITEST_NATIVE_RN_VERSION = reactNativeVersion;
478
+ env.VITEST_NATIVE_ASSET_EXTS = JSON.stringify([...DEFAULT_ASSET_EXTS, ...(options?.assetExts ?? []).map((e) => e.replace(/^\./, ""))]);
478
479
  if (hotRuntime && hotRecycle.preserveGlobals?.length) env.VITEST_NATIVE_HOT_PRESERVE_GLOBALS = JSON.stringify(hotRecycle.preserveGlobals);
479
480
  if (engine === "native") {
480
481
  if (options?.mocks && Object.keys(options.mocks).length > 0) throw new Error("[vitest-native] The \"mocks\" option is only supported by engine:'mock'. The native engine runs the real react-native module and cannot safely merge arbitrary exports into it. Use vi.mock() in a setup file, mockNativeModule() for native modules, or set engine:'mock'.");
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { h as VitestNativeOptions, m as ReactNativeMock, p as Preset, t as index_d_exports } from "./index-DCSgnSj4.cjs";
1
+ import { g as VitestNativeOptions, h as ReactNativeMock, m as Preset, t as index_d_exports } from "./index-Dr3WvKWI.cjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/plugin.d.ts
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { h as VitestNativeOptions, m as ReactNativeMock, p as Preset, t as index_d_exports } from "./index-EZmVLfjU.mjs";
1
+ import { g as VitestNativeOptions, h as ReactNativeMock, m as Preset, t as index_d_exports } from "./index-DGNLmGjq.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/plugin.d.ts
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as AUTO_DETECT_PRESETS } from "./preset-map-OJm5IWuL.mjs";
2
- import { t as presets_exports } from "./presets-C9SvIaG-.mjs";
1
+ import { t as AUTO_DETECT_PRESETS } from "./preset-map-C1UwEald.mjs";
2
+ import { t as presets_exports } from "./presets-DVLDrPC-.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import path from "node:path";
@@ -470,6 +470,7 @@ function reactNative(options) {
470
470
  };
471
471
  const reactNativeVersion = resolvePackageVersion("react-native", resolvedRoot);
472
472
  if (reactNativeVersion) env.VITEST_NATIVE_RN_VERSION = reactNativeVersion;
473
+ env.VITEST_NATIVE_ASSET_EXTS = JSON.stringify([...DEFAULT_ASSET_EXTS, ...(options?.assetExts ?? []).map((e) => e.replace(/^\./, ""))]);
473
474
  if (hotRuntime && hotRecycle.preserveGlobals?.length) env.VITEST_NATIVE_HOT_PRESERVE_GLOBALS = JSON.stringify(hotRecycle.preserveGlobals);
474
475
  if (engine === "native") {
475
476
  if (options?.mocks && Object.keys(options.mocks).length > 0) throw new Error("[vitest-native] The \"mocks\" option is only supported by engine:'mock'. The native engine runs the real react-native module and cannot safely merge arbitrary exports into it. Use vi.mock() in a setup file, mockNativeModule() for native modules, or set engine:'mock'.");
@@ -19,10 +19,29 @@ export function installRequireHooks(
19
19
  transformPkgs = [],
20
20
  platform = "ios",
21
21
  reactNativeVersion = "0.0.0",
22
+ assetExts = [],
22
23
  ) {
23
24
  if (globalThis.__vitest_native_require_hooks_installed) return;
24
25
  globalThis.__vitest_native_require_hooks_installed = true;
25
26
 
27
+ // Asset requires (`require('./logo.png')`, `require('./Icon.ttf')`) reaching
28
+ // Node's CJS loader must be stubbed, not compiled — otherwise the binary falls
29
+ // through to the `.js` handler and throws "SyntaxError: Invalid or unexpected
30
+ // token". RN's packager and Jest's asset transform both stub these (incl.
31
+ // fonts); the Vite graph already does too, so we match it here (module.exports =
32
+ // basename string) for the Node path. (Font-loading libraries like
33
+ // @react-native-vector-icons are shadowed by their preset, so they never inspect
34
+ // the stubbed font require.)
35
+ const NON_ASSET = new Set([".js", ".cjs", ".mjs", ".ts", ".tsx", ".json", ".node"]);
36
+ for (const raw of assetExts) {
37
+ const ext = "." + String(raw).replace(/^\./, "");
38
+ if (NON_ASSET.has(ext) || Module._extensions[ext]) continue;
39
+ Module._extensions[ext] = function (mod, filename) {
40
+ const basename = filename.replace(/\\/g, "/").split("/").pop() || filename;
41
+ mod.exports = basename;
42
+ };
43
+ }
44
+
26
45
  // Configured third-party packages to also transform (Flow/TS/JSX stripped).
27
46
  const isExtra = buildPkgMatcher(transformPkgs);
28
47
 
@@ -9,6 +9,8 @@ import { resolvePlatformFile } from "./resolve.mjs";
9
9
  import { buildPkgMatcher } from "./match.mjs";
10
10
 
11
11
  const RN_PATH = /[\\/](react-native|@react-native)[\\/]/;
12
+ // React Native's main entry (`react-native/index.js`).
13
+ const RN_INDEX = /[\\/]react-native[\\/]index\.js$/;
12
14
  const TRANSFORMABLE = /\.(jsx?|tsx?|mjs|cjs)$/;
13
15
  // Extensions/index candidates for bundler-style extensionless resolution.
14
16
  const RESOLVE_EXTS = [".js", ".cjs", ".mjs", ".json", ".jsx", ".ts", ".tsx"];
@@ -109,6 +111,29 @@ export async function load(url, context, nextLoad) {
109
111
  if (!isRN && !isExtra(norm)) return nextLoad(url, context);
110
112
 
111
113
  if (isRN) {
114
+ // RN's main index exports everything via lazy getters (`module.exports = {
115
+ // get Appearance() {…}, … }`). When Node imports that CommonJS module from an
116
+ // externalized ESM lib, cjs-module-lexer can't see getter exports, so
117
+ // `import { Appearance } from 'react-native'` throws "does not provide an
118
+ // export named 'Appearance'". Serve a thin CJS re-export of the real
119
+ // (Flow-stripped) index, plus a dead `0 && (module.exports = { … })` hint that
120
+ // cjs-module-lexer DOES recognize — so Node sees the named exports while the
121
+ // real getters stay lazy (no eager load of RN's whole surface). The require()
122
+ // of react-native here goes through the separate Module._extensions hook
123
+ // (hooks.mjs), not this loader, so there's no recursion. Names come from the
124
+ // index's own `get X()` declarations.
125
+ if (RN_INDEX.test(norm)) {
126
+ const src = fs.readFileSync(file, "utf8");
127
+ const names = [
128
+ ...new Set([...src.matchAll(/\bget\s+([A-Za-z_$][\w$]*)\s*\(/g)].map((m) => m[1])),
129
+ ].filter((n) => n !== "default" && n !== "__esModule");
130
+ const facade = [
131
+ `const { createRequire } = require("node:module");`,
132
+ `module.exports = createRequire(${JSON.stringify(url)})(${JSON.stringify(file)});`,
133
+ `0 && (module.exports = { ${names.join(", ")} });`,
134
+ ].join("\n");
135
+ return { format: "commonjs", source: facade, shortCircuit: true };
136
+ }
112
137
  const boundary = boundarySourceFor(norm, PLATFORM, REACT_NATIVE_VERSION);
113
138
  if (boundary != null) return { format: "commonjs", source: boundary, shortCircuit: true };
114
139
  if (norm.endsWith(".js")) {
@@ -8,9 +8,20 @@
8
8
  // (resident-library lazy init — must be preserved across files, it never
9
9
  // re-runs) and test-phase state (pollution the next file's reset removes).
10
10
  // See reset.mjs for the full attribution model.
11
- import { VitestTestRunner } from "vitest/runners";
11
+ // vitest >=4.1 exports TestRunner from the main entry; <4.1 only exposes it as
12
+ // VitestTestRunner via the (now-deprecated) "vitest/runners" subpath. Prefer the
13
+ // main entry so 4.1+ doesn't print a deprecation warning, and fall back for
14
+ // 4.0.x — the deprecated path is imported ONLY when the main export is absent,
15
+ // so 4.1+ never triggers the warning. A namespace import (not a named one) keeps
16
+ // a missing export as `undefined` instead of an ESM link error on 4.0.x.
17
+ import * as vitest from "vitest";
12
18
 
13
- export default class NativeHotRunner extends VitestTestRunner {
19
+ let TestRunner = vitest.TestRunner;
20
+ if (!TestRunner) {
21
+ ({ VitestTestRunner: TestRunner } = await import("vitest/runners"));
22
+ }
23
+
24
+ export default class NativeHotRunner extends TestRunner {
14
25
  async onBeforeRunFiles(files) {
15
26
  globalThis.__vitest_native_hot_bless?.();
16
27
  return super.onBeforeRunFiles?.(files);
@@ -45,6 +45,12 @@ try {
45
45
  if (process.env.VITEST_NATIVE_TRANSFORM)
46
46
  transformPkgs = JSON.parse(process.env.VITEST_NATIVE_TRANSFORM);
47
47
  } catch {}
48
+ // Asset extensions the Node require-hook should stub (matches the Vite graph).
49
+ let assetExts = [];
50
+ try {
51
+ if (process.env.VITEST_NATIVE_ASSET_EXTS)
52
+ assetExts = JSON.parse(process.env.VITEST_NATIVE_ASSET_EXTS);
53
+ } catch {}
48
54
 
49
55
  // --- Third-party preset mocks ---
50
56
  //
@@ -103,7 +109,7 @@ if (!globalThis.__vitest_native_loader_registered) {
103
109
  data: { projectRoot, platform, reactNativeVersion, transformPkgs, presetExports },
104
110
  });
105
111
  }
106
- installRequireHooks(projectRoot, transformPkgs, platform, reactNativeVersion);
112
+ installRequireHooks(projectRoot, transformPkgs, platform, reactNativeVersion, assetExts);
107
113
 
108
114
  // Build the mock objects now that the require hooks are installed (preset
109
115
  // factories may lazily resolve react-native at render time).
@@ -27,10 +27,15 @@ const platform = process.env.VITEST_NATIVE_PLATFORM === "android" ? "android" :
27
27
  const reactNativeVersion = process.env.VITEST_NATIVE_RN_VERSION || "0.0.0";
28
28
  let transformPkgs = [];
29
29
  let preserveGlobals = [];
30
+ let assetExts = [];
30
31
  try {
31
32
  if (process.env.VITEST_NATIVE_TRANSFORM)
32
33
  transformPkgs = JSON.parse(process.env.VITEST_NATIVE_TRANSFORM);
33
34
  } catch {}
35
+ try {
36
+ if (process.env.VITEST_NATIVE_ASSET_EXTS)
37
+ assetExts = JSON.parse(process.env.VITEST_NATIVE_ASSET_EXTS);
38
+ } catch {}
34
39
  try {
35
40
  if (process.env.VITEST_NATIVE_HOT_PRESERVE_GLOBALS)
36
41
  preserveGlobals = JSON.parse(process.env.VITEST_NATIVE_HOT_PRESERVE_GLOBALS);
@@ -48,7 +53,7 @@ if (diagnostics) {
48
53
  // listener tracking in reset.mjs, so RN's own boot state is preserved across
49
54
  // per-file resets rather than wrongly torn down with test pollution.
50
55
  installGlobals();
51
- installRequireHooks(projectRoot, transformPkgs, platform, reactNativeVersion);
56
+ installRequireHooks(projectRoot, transformPkgs, platform, reactNativeVersion, assetExts);
52
57
  try {
53
58
  const req = createRequire(path.join(projectRoot, "package.json"));
54
59
  const RN = req("react-native");
@@ -18,7 +18,9 @@ const AUTO_DETECT_PRESETS = {
18
18
  "react-native-device-info": "deviceInfo",
19
19
  "react-native-mmkv": "mmkv",
20
20
  "react-native-svg": "svg",
21
- "react-native-webview": "webview"
21
+ "react-native-webview": "webview",
22
+ "@react-native-vector-icons/common": "vectorIcons",
23
+ "react-native-vector-icons": "vectorIcons"
22
24
  };
23
25
  //#endregion
24
26
  export { AUTO_DETECT_PRESETS as t };
@@ -18,7 +18,9 @@ const AUTO_DETECT_PRESETS = {
18
18
  "react-native-device-info": "deviceInfo",
19
19
  "react-native-mmkv": "mmkv",
20
20
  "react-native-svg": "svg",
21
- "react-native-webview": "webview"
21
+ "react-native-webview": "webview",
22
+ "@react-native-vector-icons/common": "vectorIcons",
23
+ "react-native-vector-icons": "vectorIcons"
22
24
  };
23
25
  //#endregion
24
26
  Object.defineProperty(exports, "AUTO_DETECT_PRESETS", {
@@ -1741,6 +1741,65 @@ function webview() {
1741
1741
  };
1742
1742
  }
1743
1743
  //#endregion
1744
+ //#region src/presets/vector-icons.ts
1745
+ const DEFAULT_ICON_SIZE = 12;
1746
+ const DEFAULT_ICON_COLOR = "black";
1747
+ function vectorIcons() {
1748
+ return {
1749
+ name: "vectorIcons",
1750
+ modules: { "@react-native-vector-icons/common": {
1751
+ exports: [
1752
+ "createIconSet",
1753
+ "DEFAULT_ICON_COLOR",
1754
+ "DEFAULT_ICON_SIZE",
1755
+ "isDynamicLoadingEnabled",
1756
+ "isDynamicLoadingSupported",
1757
+ "setDynamicLoadingEnabled",
1758
+ "setDynamicLoadingErrorCallback"
1759
+ ],
1760
+ factory: () => {
1761
+ const createIconSet = (_glyphMap, _options) => {
1762
+ const Icon = react.default.forwardRef((props, ref) => {
1763
+ const { size = DEFAULT_ICON_SIZE, color = DEFAULT_ICON_COLOR, style, children, ...rest } = props;
1764
+ return react.default.createElement("Text", {
1765
+ ref,
1766
+ selectable: false,
1767
+ ...rest,
1768
+ style: [{
1769
+ fontSize: size,
1770
+ color
1771
+ }, style]
1772
+ }, children);
1773
+ });
1774
+ Icon.displayName = "Icon";
1775
+ Icon.getImageSource = async () => null;
1776
+ Icon.getImageSourceSync = () => null;
1777
+ Icon.getFontFamily = () => "";
1778
+ Icon.hasIcon = () => false;
1779
+ Icon.getRawGlyphMap = () => ({});
1780
+ Icon.loadFont = async () => {};
1781
+ return Icon;
1782
+ };
1783
+ const noop = () => {};
1784
+ return {
1785
+ createIconSet,
1786
+ DEFAULT_ICON_COLOR,
1787
+ DEFAULT_ICON_SIZE,
1788
+ isDynamicLoadingEnabled: () => false,
1789
+ isDynamicLoadingSupported: () => false,
1790
+ setDynamicLoadingEnabled: noop,
1791
+ setDynamicLoadingErrorCallback: noop,
1792
+ default: {
1793
+ createIconSet,
1794
+ DEFAULT_ICON_COLOR,
1795
+ DEFAULT_ICON_SIZE
1796
+ }
1797
+ };
1798
+ }
1799
+ } }
1800
+ };
1801
+ }
1802
+ //#endregion
1744
1803
  //#region src/presets/index.ts
1745
1804
  var presets_exports = /* @__PURE__ */ require_chunk.__exportAll({
1746
1805
  asyncStorage: () => asyncStorage,
@@ -1753,6 +1812,7 @@ var presets_exports = /* @__PURE__ */ require_chunk.__exportAll({
1753
1812
  safeAreaContext: () => safeAreaContext,
1754
1813
  screens: () => screens,
1755
1814
  svg: () => svg,
1815
+ vectorIcons: () => vectorIcons,
1756
1816
  webview: () => webview
1757
1817
  });
1758
1818
  //#endregion
@@ -1834,6 +1894,12 @@ Object.defineProperty(exports, "svg", {
1834
1894
  return svg;
1835
1895
  }
1836
1896
  });
1897
+ Object.defineProperty(exports, "vectorIcons", {
1898
+ enumerable: true,
1899
+ get: function() {
1900
+ return vectorIcons;
1901
+ }
1902
+ });
1837
1903
  Object.defineProperty(exports, "webview", {
1838
1904
  enumerable: true,
1839
1905
  get: function() {
@@ -1739,6 +1739,65 @@ function webview() {
1739
1739
  };
1740
1740
  }
1741
1741
  //#endregion
1742
+ //#region src/presets/vector-icons.ts
1743
+ const DEFAULT_ICON_SIZE = 12;
1744
+ const DEFAULT_ICON_COLOR = "black";
1745
+ function vectorIcons() {
1746
+ return {
1747
+ name: "vectorIcons",
1748
+ modules: { "@react-native-vector-icons/common": {
1749
+ exports: [
1750
+ "createIconSet",
1751
+ "DEFAULT_ICON_COLOR",
1752
+ "DEFAULT_ICON_SIZE",
1753
+ "isDynamicLoadingEnabled",
1754
+ "isDynamicLoadingSupported",
1755
+ "setDynamicLoadingEnabled",
1756
+ "setDynamicLoadingErrorCallback"
1757
+ ],
1758
+ factory: () => {
1759
+ const createIconSet = (_glyphMap, _options) => {
1760
+ const Icon = React.forwardRef((props, ref) => {
1761
+ const { size = DEFAULT_ICON_SIZE, color = DEFAULT_ICON_COLOR, style, children, ...rest } = props;
1762
+ return React.createElement("Text", {
1763
+ ref,
1764
+ selectable: false,
1765
+ ...rest,
1766
+ style: [{
1767
+ fontSize: size,
1768
+ color
1769
+ }, style]
1770
+ }, children);
1771
+ });
1772
+ Icon.displayName = "Icon";
1773
+ Icon.getImageSource = async () => null;
1774
+ Icon.getImageSourceSync = () => null;
1775
+ Icon.getFontFamily = () => "";
1776
+ Icon.hasIcon = () => false;
1777
+ Icon.getRawGlyphMap = () => ({});
1778
+ Icon.loadFont = async () => {};
1779
+ return Icon;
1780
+ };
1781
+ const noop = () => {};
1782
+ return {
1783
+ createIconSet,
1784
+ DEFAULT_ICON_COLOR,
1785
+ DEFAULT_ICON_SIZE,
1786
+ isDynamicLoadingEnabled: () => false,
1787
+ isDynamicLoadingSupported: () => false,
1788
+ setDynamicLoadingEnabled: noop,
1789
+ setDynamicLoadingErrorCallback: noop,
1790
+ default: {
1791
+ createIconSet,
1792
+ DEFAULT_ICON_COLOR,
1793
+ DEFAULT_ICON_SIZE
1794
+ }
1795
+ };
1796
+ }
1797
+ } }
1798
+ };
1799
+ }
1800
+ //#endregion
1742
1801
  //#region src/presets/index.ts
1743
1802
  var presets_exports = /* @__PURE__ */ __exportAll({
1744
1803
  asyncStorage: () => asyncStorage,
@@ -1751,7 +1810,8 @@ var presets_exports = /* @__PURE__ */ __exportAll({
1751
1810
  safeAreaContext: () => safeAreaContext,
1752
1811
  screens: () => screens,
1753
1812
  svg: () => svg,
1813
+ vectorIcons: () => vectorIcons,
1754
1814
  webview: () => webview
1755
1815
  });
1756
1816
  //#endregion
1757
- export { deviceInfo as a, asyncStorage as c, gestureHandler as d, createPressableMock as f, mmkv as i, navigation as l, reanimated as m, webview as n, expo as o, buildPressableHostProps as p, svg as r, screens as s, presets_exports as t, safeAreaContext as u };
1817
+ export { mmkv as a, screens as c, safeAreaContext as d, gestureHandler as f, reanimated as h, svg as i, asyncStorage as l, buildPressableHostProps as m, vectorIcons as n, deviceInfo as o, createPressableMock as p, webview as r, expo as s, presets_exports as t, navigation as u };
package/dist/presets.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_presets = require("./presets-E0yIUMJP.cjs");
2
+ const require_presets = require("./presets-BPVVlfI2.cjs");
3
3
  exports.asyncStorage = require_presets.asyncStorage;
4
4
  exports.deviceInfo = require_presets.deviceInfo;
5
5
  exports.expo = require_presets.expo;
@@ -10,4 +10,5 @@ exports.reanimated = require_presets.reanimated;
10
10
  exports.safeAreaContext = require_presets.safeAreaContext;
11
11
  exports.screens = require_presets.screens;
12
12
  exports.svg = require_presets.svg;
13
+ exports.vectorIcons = require_presets.vectorIcons;
13
14
  exports.webview = require_presets.webview;
@@ -1,2 +1,2 @@
1
- import { a as deviceInfo, c as asyncStorage, d as gestureHandler, f as reanimated, i as mmkv, l as navigation, n as webview, o as expo, r as svg, s as screens, u as safeAreaContext } from "./index-DCSgnSj4.cjs";
2
- export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, webview };
1
+ import { a as mmkv, c as screens, d as safeAreaContext, f as gestureHandler, i as svg, l as asyncStorage, n as vectorIcons, o as deviceInfo, p as reanimated, r as webview, s as expo, u as navigation } from "./index-Dr3WvKWI.cjs";
2
+ export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
@@ -1,2 +1,2 @@
1
- import { a as deviceInfo, c as asyncStorage, d as gestureHandler, f as reanimated, i as mmkv, l as navigation, n as webview, o as expo, r as svg, s as screens, u as safeAreaContext } from "./index-EZmVLfjU.mjs";
2
- export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, webview };
1
+ import { a as mmkv, c as screens, d as safeAreaContext, f as gestureHandler, i as svg, l as asyncStorage, n as vectorIcons, o as deviceInfo, p as reanimated, r as webview, s as expo, u as navigation } from "./index-DGNLmGjq.mjs";
2
+ export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
package/dist/presets.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as deviceInfo, c as asyncStorage, d as gestureHandler, i as mmkv, l as navigation, m as reanimated, n as webview, o as expo, r as svg, s as screens, u as safeAreaContext } from "./presets-C9SvIaG-.mjs";
2
- export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, webview };
1
+ import { a as mmkv, c as screens, d as safeAreaContext, f as gestureHandler, h as reanimated, i as svg, l as asyncStorage, n as vectorIcons, o as deviceInfo, r as webview, s as expo, u as navigation } from "./presets-DVLDrPC-.mjs";
2
+ export { asyncStorage, deviceInfo, expo, gestureHandler, mmkv, navigation, reanimated, safeAreaContext, screens, svg, vectorIcons, webview };
package/dist/setup.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require("./chunk-CZWwpsFl.cjs");
2
- const require_preset_map = require("./preset-map-C3jxnkiX.cjs");
3
- const require_presets = require("./presets-E0yIUMJP.cjs");
2
+ const require_preset_map = require("./preset-map-CNBOeqAu.cjs");
3
+ const require_presets = require("./presets-BPVVlfI2.cjs");
4
4
  const require_serializer = require("./serializer.cjs");
5
5
  const require_matchers = require("./matchers.cjs");
6
6
  let node_path = require("node:path");
@@ -708,13 +708,14 @@ function colorToRgba(input) {
708
708
  parseInt(n.slice(6, 8), 16) / 255
709
709
  ];
710
710
  }
711
- if (m = s.match(/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/)) return [
711
+ const compact = s.replace(/\s+/g, "");
712
+ if (m = compact.match(/^rgb\(([\d.]+),([\d.]+),([\d.]+)\)$/)) return [
712
713
  +m[1],
713
714
  +m[2],
714
715
  +m[3],
715
716
  1
716
717
  ];
717
- if (m = s.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/)) return [
718
+ if (m = compact.match(/^rgba\(([\d.]+),([\d.]+),([\d.]+),([\d.]+)\)$/)) return [
718
719
  +m[1],
719
720
  +m[2],
720
721
  +m[3],
@@ -939,7 +940,7 @@ const namedColorMap = {
939
940
  ]
940
941
  };
941
942
  function parseColorString(color) {
942
- const rgba = color.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/);
943
+ const rgba = color.replace(/\s+/g, "").match(/^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/);
943
944
  if (rgba) return [
944
945
  parseInt(rgba[1]),
945
946
  parseInt(rgba[2]),
@@ -1057,9 +1058,39 @@ function createAnimation(onStart) {
1057
1058
  reset: vitest.vi.fn()
1058
1059
  };
1059
1060
  }
1061
+ function resolveAnimatedLeaf(v) {
1062
+ if (v instanceof AnimatedValue) return v.getValue();
1063
+ if (v && typeof v === "object" && typeof v.__getValue === "function") return v.__getValue();
1064
+ if (v && typeof v === "object" && typeof v.getValue === "function") return v.getValue();
1065
+ return v;
1066
+ }
1067
+ function resolveAnimatedStyle(style) {
1068
+ if (Array.isArray(style)) return style.map(resolveAnimatedStyle);
1069
+ const asLeaf = resolveAnimatedLeaf(style);
1070
+ if (asLeaf !== style) return asLeaf;
1071
+ if (style && typeof style === "object") {
1072
+ const out = {};
1073
+ for (const key of Object.keys(style)) {
1074
+ const val = style[key];
1075
+ if (key === "transform" && Array.isArray(val)) out[key] = val.map((t) => t && typeof t === "object" && !(t instanceof AnimatedValue) ? Object.fromEntries(Object.keys(t).map((tk) => [tk, resolveAnimatedLeaf(t[tk])])) : resolveAnimatedLeaf(t));
1076
+ else out[key] = resolveAnimatedLeaf(val);
1077
+ }
1078
+ return out;
1079
+ }
1080
+ return style;
1081
+ }
1060
1082
  function createAnimatedWrapper(displayName) {
1083
+ const hostName = displayName.replace(/^Animated\./, "");
1061
1084
  const Component = react.default.forwardRef((props, ref) => {
1062
- return react.default.createElement(displayName, {
1085
+ if (props && props.style !== void 0) {
1086
+ const { style, ...rest } = props;
1087
+ return react.default.createElement(hostName, {
1088
+ ...rest,
1089
+ style: resolveAnimatedStyle(style),
1090
+ ref
1091
+ });
1092
+ }
1093
+ return react.default.createElement(hostName, {
1063
1094
  ...props,
1064
1095
  ref
1065
1096
  });
package/dist/setup.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as __require } from "./chunk-CjcI7cDX.mjs";
2
- import { t as AUTO_DETECT_PRESETS } from "./preset-map-OJm5IWuL.mjs";
3
- import { f as createPressableMock, p as buildPressableHostProps, t as presets_exports } from "./presets-C9SvIaG-.mjs";
2
+ import { t as AUTO_DETECT_PRESETS } from "./preset-map-C1UwEald.mjs";
3
+ import { m as buildPressableHostProps, p as createPressableMock, t as presets_exports } from "./presets-DVLDrPC-.mjs";
4
4
  import { serializer } from "./serializer.mjs";
5
5
  import { animatedMatchers } from "./matchers.mjs";
6
6
  import { createRequire } from "node:module";
@@ -706,13 +706,14 @@ function colorToRgba(input) {
706
706
  parseInt(n.slice(6, 8), 16) / 255
707
707
  ];
708
708
  }
709
- if (m = s.match(/^rgb\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/)) return [
709
+ const compact = s.replace(/\s+/g, "");
710
+ if (m = compact.match(/^rgb\(([\d.]+),([\d.]+),([\d.]+)\)$/)) return [
710
711
  +m[1],
711
712
  +m[2],
712
713
  +m[3],
713
714
  1
714
715
  ];
715
- if (m = s.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/)) return [
716
+ if (m = compact.match(/^rgba\(([\d.]+),([\d.]+),([\d.]+),([\d.]+)\)$/)) return [
716
717
  +m[1],
717
718
  +m[2],
718
719
  +m[3],
@@ -937,7 +938,7 @@ const namedColorMap = {
937
938
  ]
938
939
  };
939
940
  function parseColorString(color) {
940
- const rgba = color.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/);
941
+ const rgba = color.replace(/\s+/g, "").match(/^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/);
941
942
  if (rgba) return [
942
943
  parseInt(rgba[1]),
943
944
  parseInt(rgba[2]),
@@ -1055,9 +1056,39 @@ function createAnimation(onStart) {
1055
1056
  reset: vi.fn()
1056
1057
  };
1057
1058
  }
1059
+ function resolveAnimatedLeaf(v) {
1060
+ if (v instanceof AnimatedValue) return v.getValue();
1061
+ if (v && typeof v === "object" && typeof v.__getValue === "function") return v.__getValue();
1062
+ if (v && typeof v === "object" && typeof v.getValue === "function") return v.getValue();
1063
+ return v;
1064
+ }
1065
+ function resolveAnimatedStyle(style) {
1066
+ if (Array.isArray(style)) return style.map(resolveAnimatedStyle);
1067
+ const asLeaf = resolveAnimatedLeaf(style);
1068
+ if (asLeaf !== style) return asLeaf;
1069
+ if (style && typeof style === "object") {
1070
+ const out = {};
1071
+ for (const key of Object.keys(style)) {
1072
+ const val = style[key];
1073
+ if (key === "transform" && Array.isArray(val)) out[key] = val.map((t) => t && typeof t === "object" && !(t instanceof AnimatedValue) ? Object.fromEntries(Object.keys(t).map((tk) => [tk, resolveAnimatedLeaf(t[tk])])) : resolveAnimatedLeaf(t));
1074
+ else out[key] = resolveAnimatedLeaf(val);
1075
+ }
1076
+ return out;
1077
+ }
1078
+ return style;
1079
+ }
1058
1080
  function createAnimatedWrapper(displayName) {
1081
+ const hostName = displayName.replace(/^Animated\./, "");
1059
1082
  const Component = React.forwardRef((props, ref) => {
1060
- return React.createElement(displayName, {
1083
+ if (props && props.style !== void 0) {
1084
+ const { style, ...rest } = props;
1085
+ return React.createElement(hostName, {
1086
+ ...rest,
1087
+ style: resolveAnimatedStyle(style),
1088
+ ref
1089
+ });
1090
+ }
1091
+ return React.createElement(hostName, {
1061
1092
  ...props,
1062
1093
  ref
1063
1094
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-native",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "description": "Run real React Native tests under Vitest. One install, zero config.",
6
6
  "license": "MIT",
@@ -150,6 +150,8 @@
150
150
  },
151
151
  "devDependencies": {
152
152
  "@babel/core": "^7.29.7",
153
+ "@react-native-vector-icons/common": "13.0.1",
154
+ "@react-native-vector-icons/material-icons": "13.1.2",
153
155
  "@react-native/babel-preset": "^0.85.3",
154
156
  "@react-navigation/native": "7.2.5",
155
157
  "@react-navigation/native-stack": "7.16.0",
@@ -159,6 +161,7 @@
159
161
  "@vitest/coverage-v8": "4.1.8",
160
162
  "expo-constants": "56.0.16",
161
163
  "expo-status-bar": "56.0.4",
164
+ "ext-rn-named-lib": "file:./tests-native/fixtures/ext-rn-named-lib",
162
165
  "react": "^19.2.3",
163
166
  "react-native": "^0.85.3",
164
167
  "react-native-gesture-handler": "3.0.0",
@@ -167,7 +170,7 @@
167
170
  "react-native-worklets": "0.9.1",
168
171
  "react-test-renderer": "^19.2.3",
169
172
  "tsdown": "0.21.10",
170
- "typescript": "5.9.3",
173
+ "typescript": "6.0.3",
171
174
  "vite": "^8.0.5",
172
175
  "vitest": "^4.1.8"
173
176
  },