vitest-native 0.10.0 → 0.11.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 +257 -0
- package/README.md +1 -0
- package/dist/cli.cjs +25 -7
- package/dist/cli.mjs +22 -4
- package/dist/{ecosystem-IuZ-Gv0R.cjs → ecosystem-DGlajfDG.cjs} +280 -14
- package/dist/{ecosystem-CO5vqExO.mjs → ecosystem-DJMGR2YY.mjs} +254 -12
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.mjs +1 -1
- package/dist/{index-BJL4cQ-l.d.cts → index-CrMeE8rd.d.mts} +5 -5
- package/dist/{index-CvCU0cLl.d.mts → index-DIMbjH8R.d.cts} +6 -3
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +78 -48
- package/dist/jest-compat.cjs +4 -4
- package/dist/jest-compat.d.cts +0 -1
- package/dist/jest-compat.d.mts +0 -1
- package/dist/jest-compat.mjs +2 -2
- package/dist/native/hooks.mjs +77 -12
- package/dist/native/loader.mjs +10 -5
- package/dist/native/match.d.mts +33 -0
- package/dist/native/match.mjs +94 -22
- package/dist/native/registry.mjs +30 -2
- package/dist/{pool-CFND7plG.cjs → pool-BU-1ecIF.cjs} +6 -6
- package/dist/{pool-Bcxp4Qrg.mjs → pool-Bcxn9a3I.mjs} +3 -3
- package/dist/{preset-map-DxilQ4pI.cjs → preset-map-BoG19dLa.cjs} +1 -0
- package/dist/{preset-map-BpDG_D5m.mjs → preset-map-DuX0ocdn.mjs} +1 -0
- package/dist/{presets-BGTqVH6C.cjs → presets-CwO_c4aL.cjs} +131 -6
- package/dist/{presets-CK85x8ey.mjs → presets-IStcJEOa.mjs} +123 -4
- package/dist/presets.d.mts +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{chunk-CjcI7cDX.mjs → rolldown-runtime-BhDjJH2R.mjs} +1 -1
- package/dist/{chunk-CZWwpsFl.cjs → rolldown-runtime-C0BPl7ul.cjs} +1 -1
- package/dist/serializer.cjs +1 -1
- package/dist/serializer.mjs +1 -1
- package/dist/setup.d.mts +1 -1
- package/dist/setup.mjs +5 -5
- package/docs/versioning.md +1 -1
- package/package.json +17 -15
- /package/dist/{errors-flXDIeWk.cjs → errors-B3lJK46O.cjs} +0 -0
- /package/dist/{errors-Dm5yLNTF.mjs → errors-CxoBUfVJ.mjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,262 @@
|
|
|
1
1
|
# vitest-native
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ea133b6: Only walk the dependency closure of packages the project declares
|
|
8
|
+
|
|
9
|
+
Fixes a regression in 0.11.0. In a workspace holding both a library and a React
|
|
10
|
+
Native or Expo application — the canonical monorepo shape — the application's mere
|
|
11
|
+
presence could stop the library's tests from loading:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
ReferenceError: [vitest-native] Failed to transform '@babel/runtime' … for platform 'ios'.
|
|
15
|
+
Caused by: ReferenceError: Cannot access 'v' before initialization
|
|
16
|
+
Test Files 1 failed | Tests: no tests
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
0.11.0 began compiling a detected package's dependency closure, so that a library
|
|
20
|
+
shipping untranspiled JSX inside a transitive dependency would work without naming it
|
|
21
|
+
in `transform: [...]`. Candidates are collected from every manifest in the workspace,
|
|
22
|
+
which is how a library the application depends on is found at all — but applied to a
|
|
23
|
+
closure walk, that breadth stops being free. A sibling Expo application is detected on
|
|
24
|
+
its own manifest, and walking its dependencies pulled the entire Expo and Metro
|
|
25
|
+
toolchain into the Babel transform set of a package that depends on none of it: over
|
|
26
|
+
250 packages in a two-package reproduction, `@babel/runtime` and Metro's `lru-cache`
|
|
27
|
+
chain among them.
|
|
28
|
+
|
|
29
|
+
Those are not inert. React Native and Babel load them, and compiling the transform's
|
|
30
|
+
own toolchain re-enters Babel while it is still initialising — which surfaces as a
|
|
31
|
+
`Cannot access 'v' before initialization` naming files the project never mentioned.
|
|
32
|
+
The existing toolchain exclusion covers what `@babel/core` reaches and so did not
|
|
33
|
+
catch either of them.
|
|
34
|
+
|
|
35
|
+
The closure now starts only from packages the run itself declares — the package under
|
|
36
|
+
test, and any manifest above it, which is where a workspace keeping its React Native
|
|
37
|
+
libraries at the repository root declares them. A package only a sibling declares is
|
|
38
|
+
that sibling's business. Transitive compilation is unaffected: a dependency reached
|
|
39
|
+
through the walk is declared by its own parent, which is what makes it transitive.
|
|
40
|
+
|
|
41
|
+
Declaration rather than resolvability, deliberately: under pnpm every workspace member
|
|
42
|
+
is linked into a hidden directory placed on `NODE_PATH`, so a sibling's dependencies
|
|
43
|
+
do resolve from the package under test at run time, and testing reachability instead
|
|
44
|
+
lets all of them straight back through.
|
|
45
|
+
|
|
46
|
+
`@babel/runtime` and `metro` also now seed the toolchain exclusion, alongside
|
|
47
|
+
`@babel/core` and the React Native Babel preset. Neither is reachable from
|
|
48
|
+
`@babel/core`, so the existing exclusion let both through. `@babel/runtime` holds the
|
|
49
|
+
helpers Babel _emits_, so compiled output across the ecosystem requires it at run
|
|
50
|
+
time; Metro is the bundler the preset belongs to, and its `lru-cache` chain — the
|
|
51
|
+
`yallist` in the report — is loaded the same way. This matters beyond the reported
|
|
52
|
+
shape: an Expo application running its own tests declares `expo` legitimately, so its
|
|
53
|
+
closure is walked and the same packages arrive by a route the change above does not
|
|
54
|
+
affect.
|
|
55
|
+
|
|
56
|
+
In the two-package reproduction the transform set drops from 253 packages to 5 — the
|
|
57
|
+
declared dependency and its genuine closure. For an Expo application testing itself it
|
|
58
|
+
drops from 251 to 171, with `@babel/runtime`, `yallist` and Metro's cache chain no
|
|
59
|
+
longer among them.
|
|
60
|
+
|
|
61
|
+
A closure member that publishes only ES modules is left alone as well. The walk is a
|
|
62
|
+
guess that a detected package's dependencies might be untranspiled React Native
|
|
63
|
+
source; `"type": "module"` with no `react-native` build anywhere in the manifest is
|
|
64
|
+
the dependency saying the opposite. Compiling one anyway rewrote a package that
|
|
65
|
+
publishes ESM into CommonJS and handed it to Node under that format. A genuine React
|
|
66
|
+
Native library is unaffected — declaring `react-native`, by legacy field or by export
|
|
67
|
+
condition at any depth, keeps it in the closure however it publishes — and so is any
|
|
68
|
+
package named in `transform: [...]`, which was asked for explicitly.
|
|
69
|
+
|
|
70
|
+
## 0.11.0
|
|
71
|
+
|
|
72
|
+
### Minor Changes
|
|
73
|
+
|
|
74
|
+
- 912fb81: Add a `netInfo` preset for `@react-native-community/netinfo`
|
|
75
|
+
|
|
76
|
+
NetInfo was detected and compiled correctly, and still failed at the native-module
|
|
77
|
+
boundary. The generic stub answers any method with `undefined`; NetInfo awaits
|
|
78
|
+
`getCurrentState()` and reads `state.isInternetReachable` off the result, so a test
|
|
79
|
+
that called `NetInfo.fetch()` died on a TypeError and an unhandled rejection.
|
|
80
|
+
|
|
81
|
+
No generic stub can infer that shape, which is what earns a preset. It is auto-detected
|
|
82
|
+
like the others, and covers the package's real runtime surface: `configure`, `fetch`,
|
|
83
|
+
`refresh`, `addEventListener`, `useNetInfo`, `useNetInfoInstance`, and the
|
|
84
|
+
`NetInfoStateType` / `NetInfoCellularGeneration` enums — which are TypeScript enums
|
|
85
|
+
re-exported through `export *`, so unlike the rest of that module they do have runtime
|
|
86
|
+
bindings.
|
|
87
|
+
|
|
88
|
+
The resting state is a connected wifi device. The real library starts at
|
|
89
|
+
`{ type: 'unknown', isConnected: null }` and resolves to the device a moment later; a
|
|
90
|
+
mock has no device, and a null resting state would send every component under test down
|
|
91
|
+
its offline branch. Tests can drive it, and `resetAllMocks()` restores it.
|
|
92
|
+
|
|
93
|
+
The package is now a devDependency, so the preset's declared exports are checked against
|
|
94
|
+
the real package's TypeScript surface by the existing fidelity gate rather than trusted.
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- f6e5a42: Check React Native API coverage on every pull request
|
|
99
|
+
|
|
100
|
+
The mock engine is documented as covering every stable React Native export, and
|
|
101
|
+
`check-compat` is the script that backs the claim: it parses the real `react-native`
|
|
102
|
+
index and fails when a stable export has no mock.
|
|
103
|
+
|
|
104
|
+
It ran only in the weekly compatibility workflow, and there against
|
|
105
|
+
`react-native@latest`. The version actually pinned in the repository was never checked
|
|
106
|
+
on a pull request. A change that moved the pinned React Native could add stable exports
|
|
107
|
+
the mock did not cover and still go green, with the gap appearing days later as a
|
|
108
|
+
canary failure against a different version.
|
|
109
|
+
|
|
110
|
+
It now runs in the pull-request gate against the pinned React Native, on the one matrix
|
|
111
|
+
leg where the React Native version is representative. The weekly canary keeps its own
|
|
112
|
+
edge run — the two answer different questions.
|
|
113
|
+
|
|
114
|
+
Currently 85 of 85 stable exports are covered.
|
|
115
|
+
|
|
116
|
+
- 12e1be3: Build with tsdown under bun's runtime
|
|
117
|
+
|
|
118
|
+
tsdown's bin declares a Node shebang, and from 0.22 it calls `Promise.withResolvers` —
|
|
119
|
+
an API Node did not ship until 21. Building on Node 20 therefore failed with
|
|
120
|
+
`TypeError: Promise.withResolvers is not a function`, which blocked the dev-dependency
|
|
121
|
+
updates that carry tsdown forward.
|
|
122
|
+
|
|
123
|
+
`build` now invokes `bunx --bun tsdown`, so the bundler runs under bun's runtime, which
|
|
124
|
+
has the API. The emitted `dist` is byte-identical either way, verified by hashing it
|
|
125
|
+
from both runtimes against tsdown 0.21 and 0.22.
|
|
126
|
+
|
|
127
|
+
This is a change to what the build toolchain runs on, not to what the package requires.
|
|
128
|
+
The published `engines` floor of Node >= 20.19 is unchanged, and the Node 20 CI legs —
|
|
129
|
+
which prove that floor and pin RNTL 12 and 13 as the lower-bound back-compat corners —
|
|
130
|
+
keep running everything they ran before.
|
|
131
|
+
|
|
132
|
+
- c0b3bb3: `doctor` reports the real Node floor, and catches RNTL 14's missing peer
|
|
133
|
+
|
|
134
|
+
Two cases where `doctor` said a project was fine while it was not.
|
|
135
|
+
|
|
136
|
+
**The Node floor was hardcoded and compared on the major only.** It printed
|
|
137
|
+
"floor: 20" and passed any Node 20.x, but the real floor moved to 20.19 — the version
|
|
138
|
+
that added `require(esm)`, which the root entry point now depends on. Node 20.0 through
|
|
139
|
+
20.18 were reported as supported. The floor is now read from this package's own
|
|
140
|
+
`engines.node`, and compared as major and minor.
|
|
141
|
+
|
|
142
|
+
**RNTL 14 declares `test-renderer` as a non-optional peer** and reconciles through it.
|
|
143
|
+
Installing RNTL 14 without it is easy — npm only warns, and any `--legacy-peer-deps`
|
|
144
|
+
install is silent — and the result is that every `render()` throws `Cannot find module
|
|
145
|
+
'test-renderer'`, naming no file and no package. `doctor` reported no blocking problems
|
|
146
|
+
for exactly that project. It now fails with the install command. RNTL 13 is unaffected
|
|
147
|
+
and is not asked for the package it does not use.
|
|
148
|
+
|
|
149
|
+
- d0fb6ba: Compile a detected package's dependencies too
|
|
150
|
+
|
|
151
|
+
`react-native-modal` — and any package like it — failed to import under the native
|
|
152
|
+
engine with a bare `SyntaxError: Unexpected token '<'`, naming no file and no package.
|
|
153
|
+
|
|
154
|
+
Detection asks each package's own manifest whether it declares `react-native`. The
|
|
155
|
+
untranspiled JSX was not in `react-native-modal`; it was in `react-native-animatable`,
|
|
156
|
+
which that package depends on. Nothing in the project declares it, so it was never a
|
|
157
|
+
candidate, and it names `react-native` in neither `dependencies` nor
|
|
158
|
+
`peerDependencies`, so the manifest test would have rejected it anyway. The documented
|
|
159
|
+
remedy, `transform: ['react-native-modal']`, does not help — only naming
|
|
160
|
+
`react-native-animatable` does, and nothing told anyone that.
|
|
161
|
+
|
|
162
|
+
A detected package's dependency closure is now compiled with it. Two exclusions keep
|
|
163
|
+
that safe, and both compute themselves rather than being lists to maintain:
|
|
164
|
+
|
|
165
|
+
- **React Native's own dependencies.** The precompiled registry reaches those through
|
|
166
|
+
pre-resolved absolute paths, so Node owns them; inlining one would give the same
|
|
167
|
+
package two owners and two instances.
|
|
168
|
+
- **The transform's own toolchain closure.** The transform runs `@babel/core`, so
|
|
169
|
+
inlining anything Babel reaches means loading it re-enters the transform while Babel
|
|
170
|
+
is mid-load.
|
|
171
|
+
|
|
172
|
+
Detection stays under a millisecond, and 120 isolated test files run in the same time
|
|
173
|
+
as before.
|
|
174
|
+
|
|
175
|
+
- cb98e1e: Never treat the package under test as an ecosystem dependency
|
|
176
|
+
|
|
177
|
+
Under `engine: 'native'` in a workspace, a test file's own
|
|
178
|
+
`import { describe, it, expect } from 'vitest'` could fail to load with:
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
Error: Vitest cannot be imported in a CommonJS module using require().
|
|
182
|
+
Test Files 1 failed | Tests: no tests
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Auto-detection reads the manifests of every workspace member, so the package under
|
|
186
|
+
test appears in the candidate set whenever a sibling — or the repository root —
|
|
187
|
+
declares it as a dependency. It also declares React Native, because it _is_ React
|
|
188
|
+
Native code, so it was detected as a third-party ecosystem package: its directory
|
|
189
|
+
became a `server.deps.external` pattern, Vitest handed every file beneath it to Node,
|
|
190
|
+
and the loader compiled them to CommonJS. A test file's `import` then became
|
|
191
|
+
`require('vitest')`, which throws before a single test runs. Suites using Vitest
|
|
192
|
+
globals instead reported a pass while still running through Node's graph.
|
|
193
|
+
|
|
194
|
+
Because it depended on whether anything happened to declare the package, the failure
|
|
195
|
+
appeared in one workspace package and not another with an identical config, and was
|
|
196
|
+
easy to misattribute to the `react-native` export condition selecting a CommonJS build
|
|
197
|
+
of some dependency. It reproduces with no such dependency in the graph.
|
|
198
|
+
|
|
199
|
+
Two changes:
|
|
200
|
+
|
|
201
|
+
- A package whose directory contains the run root is the project, not a dependency,
|
|
202
|
+
and is excluded from detection — including when a detected sibling's dependency
|
|
203
|
+
closure reaches it. Workspace libraries the project merely depends on are still
|
|
204
|
+
detected, which is what keeps them to a single module instance.
|
|
205
|
+
- A first-party test file is never externalized, even when it sits inside a workspace
|
|
206
|
+
library that is legitimately detected — the case an Nx-style run from the repository
|
|
207
|
+
root produces. Test entries belong to Vitest, not to Node. Both conventions are
|
|
208
|
+
covered: `*.test.*` / `*.spec.*` names, and files under a `__tests__` directory.
|
|
209
|
+
- The same directory anchor is skipped for a package named in `transform: [...]`,
|
|
210
|
+
which never passes through detection. A migrated Jest `transformIgnorePatterns`
|
|
211
|
+
list naming the project's own package produced the identical failure.
|
|
212
|
+
- When the run root sits above the package under test, a `test.include` pattern
|
|
213
|
+
pointing into that package now identifies it, so its own source stays in Vite's
|
|
214
|
+
graph too rather than only its test entries. A pattern with nothing literal before
|
|
215
|
+
its first wildcard — Vitest's default — says nothing about which package is the
|
|
216
|
+
project and is ignored, so workspace libraries the run merely depends on are still
|
|
217
|
+
detected.
|
|
218
|
+
- `react` and `react-is` join the packages that are never claimed by detection,
|
|
219
|
+
alongside the test library and the renderers. A package declaring `react` as a
|
|
220
|
+
runtime dependency rather than a peer dependency pulled it into the closure walk,
|
|
221
|
+
leaving the engine's most duplication-sensitive package externalized and compiled
|
|
222
|
+
as though it were untranspiled React Native source.
|
|
223
|
+
|
|
224
|
+
One case remains where a package can still end up in both graphs, and it is now
|
|
225
|
+
reported rather than silent: when an installed React Native package depends on the
|
|
226
|
+
very package whose tests are running, Node loads that package's source alongside
|
|
227
|
+
Vite's copy, and module-level state stops being shared. The engine warns, naming the
|
|
228
|
+
file and the package that required it. It cannot be resolved by choosing an owner —
|
|
229
|
+
the dependency is usually declared but never loaded, and honouring it would put the
|
|
230
|
+
project's own test files back in Node's graph.
|
|
231
|
+
|
|
232
|
+
The ownership rule the engine follows is written down in the header of
|
|
233
|
+
`native/apply.ts`.
|
|
234
|
+
|
|
235
|
+
The consumer suite now runs the workspace library's own tests, from inside the package
|
|
236
|
+
and from the workspace root, and the whole monorepo fixture is exercised under pnpm as
|
|
237
|
+
well as npm.
|
|
238
|
+
|
|
239
|
+
- d7ffd0a: Invalidate the React Native registry when any baked-in dependency changes, not just React
|
|
240
|
+
|
|
241
|
+
The precompiled registry inlines React Native's own graph and leaves everything else —
|
|
242
|
+
`react`, `invariant`, `nullthrows`, `@babel/runtime`, `stacktrace-parser` and others —
|
|
243
|
+
as a normal `require` at a **pre-resolved absolute path** compiled into the emitted
|
|
244
|
+
file. Those paths are only correct while the packages they point at stay where they
|
|
245
|
+
were, but only React Native's own files were pinned against change.
|
|
246
|
+
|
|
247
|
+
A previous fix named `react` in the cache key after upgrading React produced a null
|
|
248
|
+
React dispatcher and React Native singletons that no longer compared equal. That fixed
|
|
249
|
+
one package out of eleven. Naming the rest in the key one at a time would be a list
|
|
250
|
+
that rots — the next dependency added to React Native's graph would not be on it.
|
|
251
|
+
|
|
252
|
+
The resolved external targets are now recorded in the registry's manifest alongside
|
|
253
|
+
React Native's own files, so the existing size-and-mtime check covers them. That works
|
|
254
|
+
for both `node_modules` layouts: under bun and pnpm a version change moves the path, so
|
|
255
|
+
the stat fails; under a flat npm or yarn tree the path survives but the file changes.
|
|
256
|
+
|
|
257
|
+
Eleven packages are pinned in this repository's build. Verified by changing `invariant`
|
|
258
|
+
under a warm cache: the registry rebuilds, where before it was reused unchanged.
|
|
259
|
+
|
|
3
260
|
## 0.10.0
|
|
4
261
|
|
|
5
262
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -476,6 +476,7 @@ export default defineConfig({
|
|
|
476
476
|
| `presets.expo()` | Expo modules |
|
|
477
477
|
| `presets.deviceInfo()` | react-native-device-info |
|
|
478
478
|
| `presets.mmkv()` | react-native-mmkv |
|
|
479
|
+
| `presets.netInfo()` | @react-native-community/netinfo |
|
|
479
480
|
| `presets.svg()` | react-native-svg |
|
|
480
481
|
| `presets.webview()` | react-native-webview |
|
|
481
482
|
| `presets.vectorIcons()` | react-native-vector-icons |
|
package/dist/cli.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const require_ecosystem = require("./ecosystem-
|
|
5
|
-
const require_preset_map = require("./preset-map-
|
|
3
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
4
|
+
const require_ecosystem = require("./ecosystem-DGlajfDG.cjs");
|
|
5
|
+
const require_preset_map = require("./preset-map-BoG19dLa.cjs");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
|
-
node_fs =
|
|
7
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
8
8
|
let node_path = require("node:path");
|
|
9
|
-
node_path =
|
|
9
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
10
10
|
let node_module = require("node:module");
|
|
11
11
|
//#region src/cli/doctor.ts
|
|
12
12
|
/**
|
|
@@ -22,6 +22,21 @@ function packageVersion(root, name) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
+
* The supported Node floor, as [major, minor], read from this package's own
|
|
26
|
+
* `engines.node`. Single source: the manifest is what a package manager enforces
|
|
27
|
+
* at install time, so a diagnostic must not carry its own copy of the number.
|
|
28
|
+
*/
|
|
29
|
+
function nodeFloor() {
|
|
30
|
+
const fallback = [20, 19];
|
|
31
|
+
try {
|
|
32
|
+
const manifest = JSON.parse(node_fs.default.readFileSync(new URL("../../package.json", require("url").pathToFileURL(__filename).href), "utf8"));
|
|
33
|
+
const match = /(\d+)\.(\d+)/.exec(manifest.engines?.node ?? "");
|
|
34
|
+
return match ? [Number(match[1]), Number(match[2])] : fallback;
|
|
35
|
+
} catch {
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
25
40
|
* In Vitest's own precedence order: a `vitest.config.*` wins, and `vite.config.*`
|
|
26
41
|
* is used when there is none.
|
|
27
42
|
*
|
|
@@ -165,8 +180,10 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
165
180
|
lines.push(`vitest-native doctor — ${root}`);
|
|
166
181
|
lines.push("", "Runtime");
|
|
167
182
|
const nodeMajorMinor = nodeVersion.split(".").slice(0, 2).map(Number);
|
|
168
|
-
|
|
169
|
-
|
|
183
|
+
const [floorMajor, floorMinor] = nodeFloor();
|
|
184
|
+
const floorText = `${floorMajor}.${floorMinor}`;
|
|
185
|
+
if (nodeMajorMinor[0] > floorMajor || nodeMajorMinor[0] === floorMajor && nodeMajorMinor[1] >= floorMinor) pass(`Node ${nodeVersion} (floor: ${floorText})`);
|
|
186
|
+
else fail(`Node ${nodeVersion} — vitest-native requires Node >= ${floorText}.`);
|
|
170
187
|
lines.push("", "Peer dependencies");
|
|
171
188
|
for (const { name, minimum, maximumMajor, minimumByMajor, optional } of require_ecosystem.PEER_REQUIREMENTS) {
|
|
172
189
|
if (optional) continue;
|
|
@@ -192,6 +209,7 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
192
209
|
const rntlError = rntlReq && require_ecosystem.validatePeerDependency(rntlReq.name, rntlReq.minimum, root, rntlReq.maximumMajor, rntlReq.minimumByMajor);
|
|
193
210
|
if (rntlError) warn(rntlError);
|
|
194
211
|
else if (rntlMajor >= 14 && (nodeMajorMinor[0] < 22 || nodeMajorMinor[0] === 22 && nodeMajorMinor[1] < 13)) fail(`@testing-library/react-native ${rntl} requires Node >= 22.13, but this is Node ${nodeVersion}. Upgrade Node or pin @testing-library/react-native@13.`);
|
|
212
|
+
else if (rntlMajor >= 14 && !packageVersion(rootFor("test-renderer"), "test-renderer")) fail(`@testing-library/react-native ${rntl} requires the 'test-renderer' package, which is not installed. Every render() will fail with "Cannot find module 'test-renderer'". Install it:\n\n npm install -D test-renderer\n`);
|
|
195
213
|
else pass(`@testing-library/react-native ${rntl}${rntlMajor >= 14 ? " (14 is async: await render/fireEvent)" : ""}`);
|
|
196
214
|
}
|
|
197
215
|
lines.push("", "Auto-detected presets");
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { t as AUTO_DETECT_PRESETS } from "./preset-map-
|
|
2
|
+
import { l as validatePeerDependency, n as detectEngine, s as PEER_REQUIREMENTS, t as detectEcosystemPackages } from "./ecosystem-DJMGR2YY.mjs";
|
|
3
|
+
import { t as AUTO_DETECT_PRESETS } from "./preset-map-DuX0ocdn.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
@@ -18,6 +18,21 @@ function packageVersion(root, name) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
+
* The supported Node floor, as [major, minor], read from this package's own
|
|
22
|
+
* `engines.node`. Single source: the manifest is what a package manager enforces
|
|
23
|
+
* at install time, so a diagnostic must not carry its own copy of the number.
|
|
24
|
+
*/
|
|
25
|
+
function nodeFloor() {
|
|
26
|
+
const fallback = [20, 19];
|
|
27
|
+
try {
|
|
28
|
+
const manifest = JSON.parse(fs.readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
|
|
29
|
+
const match = /(\d+)\.(\d+)/.exec(manifest.engines?.node ?? "");
|
|
30
|
+
return match ? [Number(match[1]), Number(match[2])] : fallback;
|
|
31
|
+
} catch {
|
|
32
|
+
return fallback;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
21
36
|
* In Vitest's own precedence order: a `vitest.config.*` wins, and `vite.config.*`
|
|
22
37
|
* is used when there is none.
|
|
23
38
|
*
|
|
@@ -161,8 +176,10 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
161
176
|
lines.push(`vitest-native doctor — ${root}`);
|
|
162
177
|
lines.push("", "Runtime");
|
|
163
178
|
const nodeMajorMinor = nodeVersion.split(".").slice(0, 2).map(Number);
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
const [floorMajor, floorMinor] = nodeFloor();
|
|
180
|
+
const floorText = `${floorMajor}.${floorMinor}`;
|
|
181
|
+
if (nodeMajorMinor[0] > floorMajor || nodeMajorMinor[0] === floorMajor && nodeMajorMinor[1] >= floorMinor) pass(`Node ${nodeVersion} (floor: ${floorText})`);
|
|
182
|
+
else fail(`Node ${nodeVersion} — vitest-native requires Node >= ${floorText}.`);
|
|
166
183
|
lines.push("", "Peer dependencies");
|
|
167
184
|
for (const { name, minimum, maximumMajor, minimumByMajor, optional } of PEER_REQUIREMENTS) {
|
|
168
185
|
if (optional) continue;
|
|
@@ -188,6 +205,7 @@ function runDoctor(root, nodeVersion = process.versions.node) {
|
|
|
188
205
|
const rntlError = rntlReq && validatePeerDependency(rntlReq.name, rntlReq.minimum, root, rntlReq.maximumMajor, rntlReq.minimumByMajor);
|
|
189
206
|
if (rntlError) warn(rntlError);
|
|
190
207
|
else if (rntlMajor >= 14 && (nodeMajorMinor[0] < 22 || nodeMajorMinor[0] === 22 && nodeMajorMinor[1] < 13)) fail(`@testing-library/react-native ${rntl} requires Node >= 22.13, but this is Node ${nodeVersion}. Upgrade Node or pin @testing-library/react-native@13.`);
|
|
208
|
+
else if (rntlMajor >= 14 && !packageVersion(rootFor("test-renderer"), "test-renderer")) fail(`@testing-library/react-native ${rntl} requires the 'test-renderer' package, which is not installed. Every render() will fail with "Cannot find module 'test-renderer'". Install it:\n\n npm install -D test-renderer\n`);
|
|
191
209
|
else pass(`@testing-library/react-native ${rntl}${rntlMajor >= 14 ? " (14 is async: await render/fireEvent)" : ""}`);
|
|
192
210
|
}
|
|
193
211
|
lines.push("", "Auto-detected presets");
|