Repository navigation
Patch Changes
-
51d5899:
import * as X from 'lib'now carries every part of a component library built by esbuild or tsup with JSX preserved. The library's index re-exports a module the engine compiles, and Node read that module's names from the published file, whose JSX it could not read: the namespace held onlydefault, soX.Rootwas undefined and rendering it failed with "Element type is invalid". The engine now lists the names a module re-exports from files it compiles. No action needed. -
9def928: A snapshot of an Expo component that passes a ref as a prop, like expo-image's
Image, is stable again under the native engine. expo-modules-core'screateSnapshotFriendlyRef()is React'screateRef, so a snapshot printed the view and React's fiber tree behind each ref: thousands of lines with render timings that changed on every run. It now returns the ref jest-expo serves, which prints as"[React.ref]"and still holds its view. Runvitest -uonce to rewrite snapshots written with the old output. -
fbcebbc: Gesture Handler 3's
Touchable,RectButtonandBorderlessButtoncan be pressed from Testing Library under the native engine.userEvent.pressandfireEvent.pressnow callonPressonce, as a tap on a device does, and a disabled button takes the press without calling it. Before,userEventfound nothing to press andfireEventmissedRectButton. The engine now mocks the native button host beside the package's ownjestSetup.js, following itstestOnly_onPressconvention. Delete avi.mockthat replacedTouchablewithPressablefor this. ATouchableis found by role only withaccessible, as on iOS; pass it in your wrapper. -
21b99dd:
hangTimeoutno longer stops a run because the machine slept. On macOS, Node's timers count time asleep, so after a sleep mid-run every running test looked past its budget and the run was stopped on wake. Time the machine spends asleep now extends each limit instead, while a test stuck in synchronous code is still caught once its awake time runs out. No action needed. -
ff4dba7: Under the hot runtime on Node 22, a React Native library whose ES index is an
.mjsfile beside CommonJS files now loads. No action needed. Builds from esbuild and tsup publish this layout. vitest-native compiles the.mjsindex, and itsrequire()of a CommonJS sibling was served the ES wrapper meant for imports, which Node 22 failed to link (ERR_VM_MODULE_LINK_FAILURE: "is from a module not been linked"). Such arequire()now returns the sibling'smodule.exports, the same instance the test file's own import of it reaches, and a new one in each file. -
7569bcb: With
diagnostics: true, the hot runtime's per-file reset lines now print. No action needed. Lines such ashot reset: dropped N moduleswere written while Vitest was starting the next file, which drops console output, so they never appeared. Hot-runtime diagnostics from the worker now go to stderr. -
2f36bc5: Under the hot runtime, a library that defines a non-configurable global no longer fails every later file in the worker. No action needed. The reset before each file could not delete such a property (the
openaiSDK defines one for its provider definitions), so it threwhotRuntime state restoration failedbefore every file after the first. A property no reset can delete or replace now stays for the worker's life, as Node's own process-wide state does, anddiagnostics: truenames it. Every other global a file adds is still deleted before the next file. -
628e964:
jest.mockthrough a renamedjestfrom@jest/globalsnow applies.jestMockTransform()recognised only calls on an identifier namedjest, soimport { jest as mockJest } from '@jest/globals'followed bymockJest.mock(…)was neither hoisted nor registered, and the module stayed real. Ajestimported, required or reached as<namespace>.jestunder any name is now handled like the global. A call through a further name (const j = mockJest; j.mock(…)) fails withJEST_BINDING_NOT_FOLLOWEDinstead of being skipped. No action needed. -
63d6efa:
vitest-native migratekeeps a suite that ran the real Reanimated on the real library. A Jest setup that calls Reanimated'ssetUpTests()and mocks Reanimated nowhere ran the real library, but migrate called that setup file covered and suggested deleting it, which moved the suite onto the preset's mock, wheregetAnimatedStylereturns{}. Migrate now writespresets: { reanimated: false }for such a suite, whenreact-native-reanimatedis a declared dependency, and keeps its setup file; "delete" stays for suites that also mock Reanimated. The presets guide shows the two modes side by side (#834).Add
presets: { reanimated: false }where your Jest setup ransetUpTests()without mocking Reanimated, and keep that setup file. -
14a0b13:
vitest-native migratelists the library mocks in your own Jest setup file that the presets cover. Ajest.mock('react-native-reanimated', …), a Safe Area mock or arequire('react-native-gesture-handler/jestSetup')in asetupFilesorsetupFilesAfterEnvfile now appears under "Covered by presets — delete", as the migration guide says. A mock that keeps part of the library is listed for review instead. The report also stops callingjest-react-native, which only React Native's(jest-)?react-nativepattern produces, not installed, and lists a preset-shadowedtransformIgnorePatternsentry under "Mapped automatically" (#795, #796, #797).Delete the setup-file lines the report now lists, once the suite passes without them.
-
bca755b: Reanimated's
interpolateColorworks under the mock engine. It threwPRESET_UNAVAILABLEthere with reanimated 4.x, because its file imports React Native, which the mock engine does not transform. WheninterpolateColoris first called, the preset now compiles reanimated's own file with the project's@babel/coreand@babel/plugin-transform-modules-commonjs, which a React Native app has through its Babel preset. It returns what reanimated returns: RGB, HSV and LAB, with colour strings or numbers. A project without that Babel keeps the error, which now names the packages to install. No action needed. -
1ad8a8d: The navigation preset now has the React Navigation 7 API it lacked, so tests calling it no longer fail with "is not a function".
- Container refs gain
resetRoot,setParams,setOptions,isFocused,getId,getParent,removeListenerandemit; they anduseNavigation()gainpreload,replaceParamsandnavigateDeprecated, as mock functions. StackActions.popToandCommonActions.preload,replaceParamsandnavigateDeprecatedreturn React Navigation's action objects.StackRouter,TabRouter,DrawerRouter,NavigationProvider,createScreenFactory,createStandardNavigationFactories,NativeStackViewandcreateNativeStackScreenare exported.- Existing exports behave as before. No action needed.
- Container refs gain
-
17ab16a: A package's
.jsfile with JSX no longer stops the run with Vite's "Failed to parse source for import analysis" error under the native engine. A package that declares noreact-nativedependency or peer isn't detected, so Vite serves it uncompiled, and Vite skips JSX in.jsfiles. vitest-native now compiles JSX in such a file when Vite's parser rejects it; every file that parses is served unchanged. No action needed. A package that also ships Metro-only source, such asreact-native-calendars, still needsreactNative({ transform: ['<package>'] }), and the error now says so. -
daac3a3:
hotRuntime.freshRuntimenow works with vitest-native's presets, so it no longer declines when one that uses React is active. No action needed for vitest-native's presets. Each preset builds its mock with the Reactreact-nativeuses, the test file's own, so hooks and contexts work in every file. A preset module's factory now receives{ React }(PresetFactoryContext). Change a custom preset whose factory makes components, contexts or hooks to use it:factory: ({ React }) => …. Under the native engine, a project that resolves a second copy of React now fails withPRESET_REACT_MISMATCH. -
0b18493:
vitest-native migrateanddoctorno longer say components render the same without React Compiler. The compiler is still not needed for tests to run, but it applies to the filesprojectBabelcompiles with Babel. There a memoized child skips re-rendering, so a test that reads a value React does not track during render can see an earlier value. Other files run without it, so a test that counts renders can see more than under babel-jest (#755).Set
projectBabel: 'always'where a suite depends on React Compiler running on every file, as under babel-jest. -
705f7ae: A Reanimated derived value from a render React discards no longer keeps running, and an updater that writes a value it reads no longer recurses.
useDerivedValuestarted following its inputs during render, so a render React discarded (a Suspense throw, an error boundary) kept its updater running on every later write. It now follows them once the component commits, as Reanimated starts its mapper in an effect. An updater that wrote a value it reads overflowed the stack; the write now waits for the next change to one of its inputs. No action needed. -
ae8bfea: A cancelled run no longer waits for a stopped background build before it exits. No action needed. On Windows, a cold run cancelled with
--bailor Ctrl-C could take several more seconds to exit on a busy machine. The background process that precompiles React Native got its input on stdin, and a stop before it had read that input left a write pending that held the run open until Windows finished tearing that process down. Helper processes now read their input from a file in the project's cache directory, which is removed when they end. -
e477632: A project setup file that imports
react-nativenow runs undersequence.setupFiles: 'parallel'. The engine's own setup file ran alongside the project's, which could importreact-nativebefore its require hooks existed and fail withSyntaxError: Unexpected token 'typeof'. Its setup files now always run first, in order, and a project that sets'parallel'runs its setup files as a list. No action needed.
What's Changed
- chore(bakeoffs): re-base the external-app baselines on the supported-floor pins by @danfry1 in #832
- fix(hot-runtime): keep a non-configurable global for the worker instead of failing every later file by @danfry1 in #774
- fix(native): the engine's setup files run first under sequence.setupFiles: 'parallel' by @danfry1 in #766
- fix(native): compile JSX in a package's .js file that Vite serves uncompiled by @danfry1 in #767
- fix(hang-watch): don't count time asleep toward hangTimeout by @danfry1 in #724
- fix(presets): a Reanimated derived value follows its inputs from commit, and does not run inside itself by @danfry1 in #820
- fix(cli): say where React Compiler still applies under projectBabel: 'auto' by @danfry1 in #827
- fix(cli): migrate lists setup-file mocks the presets cover, without allowlist noise by @danfry1 in #799
- test(native): run tests that start their own Vitest run in the main native config only by @danfry1 in #752
- fix(bakeoff): say whether passes fell or only the total changed by @danfry1 in #830
- test(native): two new configs check the build stamp before loading dist/ by @danfry1 in #842
- test(scripts): validation and report scripts refuse arguments they do not read by @danfry1 in #772
- fix(native): Gesture Handler 3's buttons can be pressed from Testing Library by @danfry1 in #777
- fix(jest-compat): jest.mock through a renamed jest from @jest/globals is hoisted and applied by @danfry1 in #843
- fix(hot): preset factories build their mocks with the test file's React by @danfry1 in #756
- fix(hot-runtime): print the per-file reset's diagnostics by @danfry1 in #776
- docs(site): release notes page for 0.15 by @danfry1 in #845
- fix(hot): a compiled ES index's require() of a CommonJS sibling links on Node 22 by @danfry1 in #850
- fix(native): an imported namespace carries the names a module re-exports from files the engine compiles by @danfry1 in #769
- test(native): run the esbuild re-export ES cases under the hot runtime on Node 22 by @danfry1 in #859
- fix(presets): the navigation preset has React Navigation 7's actions, ref methods and exports by @danfry1 in #829
- fix(native): give helper processes their input in a file, not on stdin by @danfry1 in #824
- fix(cli): migrate keeps a suite that ran the real Reanimated on the real library by @danfry1 in #837
- test: leave end-to-end scratch trees to the run's temporary root by @danfry1 in #871
- test(native): time close after a cancelled run from inside the run by @danfry1 in #823
- fix(native): Expo's snapshot-friendly ref prints as "[React.ref]", as under jest-expo by @danfry1 in #852
- fix(release): publish the bin path in npm's form and check for publish-time corrections by @danfry1 in #839
- docs(migration): warn that vitest run -u runs every file by @danfry1 in #851
- fix(presets): reanimated's interpolateColor works under the mock engine by @danfry1 in #862
- chore: release 0.15.1 by @danfry1 in #872
Full Changelog: v0.15.0...v0.15.1