vitest-native 0.7.0 → 0.9.0
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 +373 -0
- package/README.md +32 -14
- package/dist/cli.cjs +506 -0
- package/dist/cli.d.cts +4 -0
- package/dist/cli.d.mts +4 -0
- package/dist/cli.mjs +502 -0
- package/dist/ecosystem-BIWaVwYL.cjs +294 -0
- package/dist/ecosystem-EFtHnKS9.mjs +256 -0
- package/dist/{index-DbfKy_bm.d.mts → index-CEgRDdhd.d.cts} +22 -3
- package/dist/{index-BgzErxHj.d.cts → index-j-0tueBr.d.mts} +20 -5
- package/dist/index.cjs +345 -200
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +341 -196
- package/dist/jest-compat/setup.mjs +65 -1
- package/dist/native/boundary.mjs +108 -30
- package/dist/native/compile-cache.mjs +45 -0
- package/dist/native/explain.mjs +69 -0
- package/dist/native/hooks.mjs +77 -4
- package/dist/native/loader.mjs +36 -7
- package/dist/native/match.mjs +107 -8
- package/dist/native/registry.mjs +471 -0
- package/dist/native/reset.mjs +18 -12
- package/dist/native/runner.mjs +13 -7
- package/dist/native/setup.mjs +44 -0
- package/dist/native/transform.mjs +88 -19
- package/dist/native/worker.mjs +13 -0
- package/dist/pool-CJmjRgsB.mjs +117 -0
- package/dist/pool-DzsEo9vv.cjs +121 -0
- package/dist/{preset-map-CNBOeqAu.cjs → preset-map-CG4FMtsl.cjs} +5 -1
- package/dist/{preset-map-C1UwEald.mjs → preset-map-CNsZKfvu.mjs} +5 -1
- package/dist/{presets-BTG8fiNF.cjs → presets-C4faM3ds.cjs} +838 -2
- package/dist/{presets-BFuAMwYQ.mjs → presets-CuDrNA_W.mjs} +761 -3
- package/dist/presets.cjs +5 -1
- package/dist/presets.d.cts +2 -2
- package/dist/presets.d.mts +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/setup.cjs +327 -347
- package/dist/setup.mjs +318 -338
- package/docs/hot-default-design.md +129 -0
- package/docs/migrating-from-jest.md +43 -7
- package/docs/migrating-from-vitest-react-native.md +1 -1
- package/docs/release-readiness.md +2 -1
- package/package.json +23 -7
- package/dist/pool-B7LBfcMQ.mjs +0 -67
- package/dist/pool-p54QV1dQ.cjs +0 -69
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Design: hot runtime as a safe default for greenfield apps
|
|
2
|
+
|
|
3
|
+
**Status:** Design proposal (not yet implemented)
|
|
4
|
+
**Basis:** the idiomatic hot-parity validation + default-flip de-risk (`validation/idiomatic/`)
|
|
5
|
+
|
|
6
|
+
## What the data established
|
|
7
|
+
|
|
8
|
+
- **Correctness is not the blocker.** On idiomatic vitest-first apps, hot is
|
|
9
|
+
correctness-identical to the default engine — single- and multi-worker, 135→1000
|
|
10
|
+
files, with a negative control proving the cross-file bleed probes are sensitive.
|
|
11
|
+
The old "hot can't be default because of state bleed" framing is dead for the
|
|
12
|
+
greenfield audience.
|
|
13
|
+
- **Memory is the real constraint, and it's a tradeoff.**
|
|
14
|
+
- Single-worker hot accumulates **~4 MB/file, unbounded** (2466 MB @500 files).
|
|
15
|
+
Recycling cannot fire single-worker (Vitest batches all files into one task),
|
|
16
|
+
so this case is structurally unsafe at large scale.
|
|
17
|
+
- Multi-worker + recycling **bounds it flat** (~1.5 GB @500–1000 files) but at
|
|
18
|
+
~1.8× the default engine, because each worker holds React Native resident.
|
|
19
|
+
- **Migration suites are out of scope.** hot is *not* clean for jest-compat
|
|
20
|
+
suites (the paper bake-off); that's a migration-tooling problem, separate from
|
|
21
|
+
the engine.
|
|
22
|
+
|
|
23
|
+
So the question is no longer *whether* hot is correct enough to default — it is —
|
|
24
|
+
but *how* to default it without the memory footgun or breaking migration suites.
|
|
25
|
+
|
|
26
|
+
## Design principles
|
|
27
|
+
|
|
28
|
+
1. **Safe when enabled.** Turning hot on must never silently grow unbounded.
|
|
29
|
+
Today `hotRuntime: true` on a single worker leaks with only a warning.
|
|
30
|
+
2. **Opt-in escalation.** Don't flip the global default for everyone in one step.
|
|
31
|
+
Make hot *safe to enable*, then *auto-enable where provably safe*, then
|
|
32
|
+
(much later, with real-world data) consider the global default.
|
|
33
|
+
3. **Honest fallbacks.** Where hot can't be made safe (single-worker large, or
|
|
34
|
+
jest-compat suites), fall back or warn — never pretend.
|
|
35
|
+
|
|
36
|
+
## Layer 1 — Bounded hot (safe defaults when `hotRuntime` is enabled)
|
|
37
|
+
|
|
38
|
+
When `hotRuntime` is truthy and the user has NOT set an explicit `memoryLimit` /
|
|
39
|
+
`recycleAfterFiles`, apply a **default per-worker memory bound** so total hot
|
|
40
|
+
memory is bounded regardless of worker count:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
perWorkerMemoryLimit = clamp(
|
|
44
|
+
floor(MEMORY_BUDGET_FRACTION * os.totalmem() / effectiveWorkers),
|
|
45
|
+
MIN_PER_WORKER, // 512 MB — below this, recycling thrashes
|
|
46
|
+
MAX_PER_WORKER, // 2 GB — above this, no point bounding
|
|
47
|
+
)
|
|
48
|
+
// MEMORY_BUDGET_FRACTION = 0.6 (total hot RSS targets ~60% of system memory)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The hot pool already implements its own `memoryLimit` recycling (custom pools
|
|
52
|
+
don't receive Vitest's vm-only `task.memoryLimit`), so this is wiring a default,
|
|
53
|
+
not new machinery. Dividing the budget by worker count keeps total memory bounded
|
|
54
|
+
as workers scale — **up to a point**: once worker count exceeds
|
|
55
|
+
`MEMORY_BUDGET_FRACTION * totalmem / MIN_PER_WORKER`, the `MIN_PER_WORKER` floor
|
|
56
|
+
engages and total memory becomes `workers * MIN_PER_WORKER`, which grows with
|
|
57
|
+
worker count again (e.g. 16 workers × 512 MB = 8 GB regardless of the fraction).
|
|
58
|
+
The floor exists because a per-worker limit below React Native's resident base
|
|
59
|
+
(~600 MB) would thrash (recycle every few files). So a **worker-count cap** is
|
|
60
|
+
still needed for the high-worker / low-memory corner — the budget division alone
|
|
61
|
+
does not bound it there.
|
|
62
|
+
|
|
63
|
+
**Single-worker is the residual unsafe case.** Recycling can't fire when Vitest
|
|
64
|
+
batches all files into one task (`isolate:false` + `maxWorkers:1`). So when hot is
|
|
65
|
+
enabled and workers resolve to 1, the bound is inert — keep the existing one-time
|
|
66
|
+
warning (already shipped) and document "run ≥2 workers for bounded hot memory."
|
|
67
|
+
Do **not** silently rewrite the user's `maxWorkers`.
|
|
68
|
+
|
|
69
|
+
## Layer 2 — `hotRuntime: 'auto'`
|
|
70
|
+
|
|
71
|
+
A third value that enables hot only when it is both *safe* and *beneficial*:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
reactNative({ engine: "native", hotRuntime: "auto" })
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Enable hot when ALL hold (else fall back to the default per-file engine):
|
|
78
|
+
|
|
79
|
+
- **Not a migration suite.** No `jestMockTransform` plugin and no jest-compat
|
|
80
|
+
setup file present (inspect the resolved Vite config in `configResolved`). hot
|
|
81
|
+
isn't clean for jest-compat patterns, so don't auto-enable there.
|
|
82
|
+
- **Multi-worker.** Resolved `maxWorkers >= 2` (so recycling can bound memory).
|
|
83
|
+
- **Enough headroom.** `os.totalmem()` comfortably exceeds
|
|
84
|
+
`effectiveWorkers * RN_RESIDENT_ESTIMATE` (~600 MB/worker).
|
|
85
|
+
|
|
86
|
+
Suite size (hot's win amortizes over many files) is only known after collection,
|
|
87
|
+
so `'auto'` keys on config-time signals; a tiny suite still works under hot, just
|
|
88
|
+
without a speed win — acceptable.
|
|
89
|
+
|
|
90
|
+
## Layer 3 — global default flip (future, gated)
|
|
91
|
+
|
|
92
|
+
Only after `'auto'` has real-world mileage would we consider making `'auto'` the
|
|
93
|
+
default for the native engine. Gating evidence: a real greenfield app validated,
|
|
94
|
+
memory behavior confirmed across CI shapes, and the migration story handled. Not
|
|
95
|
+
part of this proposal.
|
|
96
|
+
|
|
97
|
+
## Memory model (the math we are bounding)
|
|
98
|
+
|
|
99
|
+
| config | peak RSS @500 files | bounded? |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| default (isolate:true), 4w | 836 MB | yes (recreates per file) |
|
|
102
|
+
| hot, 1 worker | 2466 MB | **no** (unbounded, ~4 MB/file) |
|
|
103
|
+
| hot + recycle, 4w | 1523 MB | yes (flat to 1000 files) |
|
|
104
|
+
|
|
105
|
+
Layer 1 makes the bounded row the out-of-the-box behavior whenever workers ≥ 2.
|
|
106
|
+
|
|
107
|
+
## Guardrails & warnings
|
|
108
|
+
|
|
109
|
+
- Single-worker hot with a memory bound set → the existing "recycling INACTIVE"
|
|
110
|
+
warning (PR #55), reworded to mention the unbounded-memory risk and recommend
|
|
111
|
+
≥2 workers.
|
|
112
|
+
- `'auto'` that declines to enable hot → a one-line diagnostic explaining why
|
|
113
|
+
(jest-compat detected / single worker / low memory), so it isn't a silent no-op.
|
|
114
|
+
|
|
115
|
+
## Open questions
|
|
116
|
+
|
|
117
|
+
1. `MEMORY_BUDGET_FRACTION` — 0.6 is a guess; validate against CI shapes
|
|
118
|
+
(2-core/8 GB GitHub runners, memory-constrained containers).
|
|
119
|
+
2. Should `'auto'` also consider `process.env.CI` memory limits (cgroup limits)
|
|
120
|
+
rather than `os.totalmem()`? Containerized CI often has less than the host.
|
|
121
|
+
3. Reuse the upstream `isolate: 'modules'` work if it lands — it would remove the
|
|
122
|
+
custom-pool hacks underneath all of this.
|
|
123
|
+
|
|
124
|
+
## Rollout sequence
|
|
125
|
+
|
|
126
|
+
1. **Layer 1 (bounded hot)** — low risk, high value; makes hot safe to enable for
|
|
127
|
+
anyone today. Ship first.
|
|
128
|
+
2. **Layer 2 (`'auto'`)** — opt greenfield projects in safely.
|
|
129
|
+
3. **Layer 3 (default flip)** — only with the gating evidence above.
|
|
@@ -5,8 +5,9 @@ couple to Jest at several levels (the `jest` global, `@jest/globals`, `jest.mock
|
|
|
5
5
|
`@react-native/jest-preset`, jest-native matchers, recorded snapshots). The `vitest-native/jest-compat`
|
|
6
6
|
layer clears the *API coupling* mechanically; the rest is a small, well-defined per-suite cleanup.
|
|
7
7
|
|
|
8
|
-
This guide is
|
|
9
|
-
|
|
8
|
+
This guide is informed by migration runs against production apps, but support claims come from
|
|
9
|
+
minimal package-owned tests. External apps include custom Jest setup and migration shims, so their
|
|
10
|
+
pass counts are observations rather than capability verdicts.
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
@@ -101,6 +102,13 @@ Those are Jest/Metro config. vitest-native handles RN + third-party transformati
|
|
|
101
102
|
For *run-real pure-JS* third-party libs under the native engine, use the plugin's `transform: [...]`
|
|
102
103
|
allowlist instead of `transformIgnorePatterns`.
|
|
103
104
|
|
|
105
|
+
One case needs a manual `transform` entry: a library shipping **untranspiled JSX in `.js` files**
|
|
106
|
+
(its `package.json` `"react-native"`/`"module"` field points at `src/`). Under the native engine
|
|
107
|
+
it's external to the Vite graph, so you'll see `Failed to parse source for import analysis … If you
|
|
108
|
+
are using JSX, make sure to name the file with the .jsx or .tsx extension. File: node_modules/<lib>/…`.
|
|
109
|
+
The error names the file — add that package: `reactNative({ engine: 'native', transform: ['<lib>'] })`.
|
|
110
|
+
Same entry is needed when a `vi.mock('<lib>')` must intercept an otherwise-externalized library.
|
|
111
|
+
|
|
104
112
|
### 2f. Jest config options
|
|
105
113
|
`jest.config.js` keys (`setupFilesAfterEnv`, `moduleNameMapper`, `testEnvironment`, etc.) move to the
|
|
106
114
|
Vitest config: `setupFiles`, `resolve.alias`, `test.environment: 'node'`. `jest.setTimeout(ms)` is a
|
|
@@ -108,17 +116,45 @@ no-op under the shim (use `test.testTimeout` in config or per-test `{ timeout }`
|
|
|
108
116
|
|
|
109
117
|
---
|
|
110
118
|
|
|
111
|
-
## 3.
|
|
119
|
+
## 3. Known limits — assertions coupled to Jest's mocks
|
|
120
|
+
|
|
121
|
+
A minority of tests assert on **Jest's React Native mock internals** rather than rendered behavior.
|
|
122
|
+
The native engine runs *real* RN, so these can't be reproduced without re-mocking RN internally
|
|
123
|
+
(which defeats the point). Recognize them so you rewrite or skip rather than chase them. In our runs
|
|
124
|
+
they clustered in **component libraries** (which test RN internals directly); ordinary app suites hit
|
|
125
|
+
few or none.
|
|
126
|
+
|
|
127
|
+
- **`jest.spyOn(View.prototype, 'measure'/'measureInWindow')`** — Jest mocks `View` as a class with
|
|
128
|
+
prototype methods; real RN's `View` is a `forwardRef` with no such prototype, so the spy target is
|
|
129
|
+
`undefined`. Drive layout via `onLayout`/`fireEvent` instead, or accept as known-incompatible.
|
|
130
|
+
- **`jest.mock('react-native/Libraries/…')` of internal submodules** (e.g. `Appearance`,
|
|
131
|
+
`AccessibilityInfo`) then spying them — externalized/resident RN isn't intercepted by a submodule
|
|
132
|
+
mock. Prefer the public API from `react-native`.
|
|
133
|
+
- **`image.props.source.uri` / raw `source`-shape assertions** — real RN normalizes `source`, so the
|
|
134
|
+
raw shape differs. Native = real RN = ground truth; assert on behavior instead.
|
|
135
|
+
- **`jest.mock('react-native', …)` nested inside `beforeAll`/`describe` callbacks** — Jest doesn't
|
|
136
|
+
hoist those (they're inert); vitest-native applies mocks more consistently, which can expose a mock
|
|
137
|
+
that was silently a no-op. Move it to top level with a valid override, or drop it.
|
|
138
|
+
|
|
139
|
+
The `jest.requireActual('react-native')` clone-and-override pattern is supported (RN's module is
|
|
140
|
+
writable under the compat layer). **Expo caveat:** suites importing **Expo core** pull in Expo's
|
|
141
|
+
dev-server/init plumbing (message socket, dev tools) that expects a Metro connection and may not
|
|
142
|
+
collect without extra setup; suites using Expo *modules* via the `expo` preset are unaffected.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 4. Suggested migration recipe
|
|
112
147
|
|
|
113
148
|
1. Add the jest-compat config (section 1). Upgrade RNTL to a supported 12–14 release (2b).
|
|
114
149
|
2. Delete manual third-party native-lib mocks and `@react-native/jest-preset` (2c, 2e).
|
|
115
150
|
3. Convert any **top-level** `jest.mock(...)` to `vi.mock(...)`; leave runtime `jest.*` as-is (2a).
|
|
116
151
|
4. Run `vitest run -u` once to re-record snapshots (2d), then `vitest run` to confirm green.
|
|
117
|
-
5. Triage remaining failures —
|
|
118
|
-
issues (large-suite memory limits,
|
|
119
|
-
|
|
152
|
+
5. Triage remaining failures — a missing query update, a suite-specific mock, or a known
|
|
153
|
+
Jest-mock-coupled assertion (section 3). For runtime issues (large-suite memory limits,
|
|
154
|
+
error-boundary console noise, overriding a preset's mock), see the
|
|
155
|
+
[Troubleshooting](../README.md#troubleshooting) section.
|
|
120
156
|
|
|
121
|
-
##
|
|
157
|
+
## 5. What "done" looks like
|
|
122
158
|
|
|
123
159
|
A migrated suite runs under Vitest with: the jest-compat aliases + setup, RNTL 12–14, no manual
|
|
124
160
|
third-party native mocks, top-level mocks converted, and snapshots re-recorded. You get Vitest's
|
|
@@ -27,7 +27,7 @@ npm i -D vitest-native @react-native/babel-preset @babel/core
|
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Keep your existing `vitest`, `vite`, `react`, `react-native`, and
|
|
30
|
-
`@testing-library/react-native`. Requirements: **Vitest 4.x, Vite ^6.4.2, ^7.3.2, or ^8.0.5, the React
|
|
30
|
+
`@testing-library/react-native`. Requirements: **Vitest 4.x or 5.x, Vite ^6.4.2, ^7.3.2, or ^8.0.5, the React
|
|
31
31
|
version required by your RN release, React Native 0.81–0.86 (validated), and
|
|
32
32
|
RNTL 12–14.** RNTL 14 uses async rendering APIs and requires Node 22.13 or 24+.
|
|
33
33
|
|
|
@@ -18,7 +18,8 @@ projects, experimental surfaces are labeled, and upstream compatibility is bound
|
|
|
18
18
|
- Node 20.19 on Linux.
|
|
19
19
|
- Node 22.13 on Linux, macOS, and Windows.
|
|
20
20
|
- Patched Vite lines ^6.4.2, ^7.3.2, and ^8.0.5 through packed consumers.
|
|
21
|
-
- Vitest 4.x
|
|
21
|
+
- Vitest 4.x and 5.x: the lockfile release, the newest supported 4.x release, and 5.x
|
|
22
|
+
(against the oldest and newest supported React Native).
|
|
22
23
|
- React Native 0.81–0.85 in the full native matrix.
|
|
23
24
|
- React Native 0.86 in a pinned packed Android consumer.
|
|
24
25
|
- React Native Testing Library 12, 13, and 14.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Run real React Native tests under Vitest. One install, zero config.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"peerDependencies": {
|
|
133
133
|
"react": ">=18",
|
|
134
134
|
"vite": "^6.4.2 || ^7.3.2 || ^8.0.5",
|
|
135
|
-
"vitest": ">=4 <
|
|
135
|
+
"vitest": ">=4 <6",
|
|
136
136
|
"@testing-library/react-native": ">=12 <15",
|
|
137
137
|
"@react-native/babel-preset": "*",
|
|
138
138
|
"@babel/core": "*"
|
|
@@ -150,12 +150,14 @@
|
|
|
150
150
|
},
|
|
151
151
|
"devDependencies": {
|
|
152
152
|
"@babel/core": "^7.29.7",
|
|
153
|
+
"@gorhom/bottom-sheet": "5.2.14",
|
|
153
154
|
"@react-native-vector-icons/common": "13.0.1",
|
|
154
155
|
"@react-native-vector-icons/material-icons": "13.1.2",
|
|
155
156
|
"@react-native/babel-preset": "^0.85.3",
|
|
156
157
|
"@react-navigation/native": "7.2.5",
|
|
157
158
|
"@react-navigation/native-stack": "7.16.0",
|
|
158
|
-
"@
|
|
159
|
+
"@shopify/flash-list": "2.3.2",
|
|
160
|
+
"@testing-library/react-native": "14.0.0",
|
|
159
161
|
"@types/node": "25.3.5",
|
|
160
162
|
"@types/react": "19.2.14",
|
|
161
163
|
"@vitest/coverage-v8": "4.1.8",
|
|
@@ -163,15 +165,22 @@
|
|
|
163
165
|
"expo-status-bar": "56.0.4",
|
|
164
166
|
"ext-platform-lib": "file:./tests-native/fixtures/ext-platform-lib",
|
|
165
167
|
"ext-rn-named-lib": "file:./tests-native/fixtures/ext-rn-named-lib",
|
|
168
|
+
"generic-mainfield-lib": "file:./tests-native/fixtures/generic-mainfield-lib",
|
|
166
169
|
"react": "^19.2.3",
|
|
167
|
-
"react-native": "^0.
|
|
170
|
+
"react-native": "^0.86.0",
|
|
168
171
|
"react-native-gesture-handler": "3.0.0",
|
|
172
|
+
"react-native-keyboard-controller": "1.21.11",
|
|
169
173
|
"react-native-reanimated": "4.3.1",
|
|
170
174
|
"react-native-safe-area-context": "5.8.0",
|
|
171
175
|
"react-native-worklets": "0.9.1",
|
|
172
176
|
"react-test-renderer": "^19.2.3",
|
|
177
|
+
"rn-condition-lib": "file:./tests-native/fixtures/rn-condition-lib",
|
|
178
|
+
"rn-ecosystem-lib": "file:./tests-native/fixtures/rn-ecosystem-lib",
|
|
179
|
+
"rn-mainfield-lib": "file:./tests-native/fixtures/rn-mainfield-lib",
|
|
180
|
+
"test-renderer": "^1.2.0",
|
|
173
181
|
"tsdown": "0.21.10",
|
|
174
182
|
"typescript": "6.0.3",
|
|
183
|
+
"untranspiled-jsx-lib": "file:./tests-native/fixtures/untranspiled-jsx-lib",
|
|
175
184
|
"vite": "^8.0.5",
|
|
176
185
|
"vitest": "^4.1.8"
|
|
177
186
|
},
|
|
@@ -189,13 +198,20 @@
|
|
|
189
198
|
"format": "oxfmt --write src/ tests/ consumer-tests/ scripts/",
|
|
190
199
|
"format:check": "oxfmt --check src/ tests/ consumer-tests/ scripts/",
|
|
191
200
|
"check-compat": "bun scripts/check-compat.ts",
|
|
201
|
+
"check:size": "node scripts/check-package-size.mjs",
|
|
192
202
|
"typecheck": "tsc --noEmit",
|
|
193
203
|
"clean": "rm -rf dist",
|
|
194
|
-
"prepublishOnly": "bun run build && bun run test && bun run test:native && bun run test:native:navigation && bun run test:native:android && bun run test:native:hot && bun run test:native:hot:isolation && bun run test:native:hot:soak && bun run
|
|
195
|
-
"crosscheck": "node scripts/crosscheck.mjs"
|
|
204
|
+
"prepublishOnly": "bun run build && bun run check:size && bun run test && bun run test:native && bun run test:native:navigation && bun run test:native:android && bun run test:native:hot && bun run test:native:hot:isolation && bun run test:native:hot:soak && bun run fidelity:check && bun run test:consumers && bun run lint && bun run typecheck",
|
|
205
|
+
"crosscheck": "node scripts/crosscheck.mjs",
|
|
206
|
+
"fidelity:report": "node scripts/fidelity-report.mjs",
|
|
207
|
+
"fidelity:check": "node scripts/fidelity-report.mjs --check && node scripts/fidelity-matrix.mjs --check",
|
|
208
|
+
"validate:hot-parity": "node validation/idiomatic/scale/run-compare.mjs"
|
|
196
209
|
},
|
|
197
210
|
"dependencies": {
|
|
198
|
-
"flow-remove-types": "^2.
|
|
211
|
+
"flow-remove-types": "^2.322.0",
|
|
199
212
|
"magic-string": "^0.30.21"
|
|
213
|
+
},
|
|
214
|
+
"bin": {
|
|
215
|
+
"vitest-native": "./dist/cli.mjs"
|
|
200
216
|
}
|
|
201
217
|
}
|
package/dist/pool-B7LBfcMQ.mjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { ThreadsPoolWorker } from "vitest/node";
|
|
3
|
-
//#region src/native/pool.ts
|
|
4
|
-
function deepEqual(a, b) {
|
|
5
|
-
if (a === b) return true;
|
|
6
|
-
if (a == null || b == null || typeof a !== "object" || typeof b !== "object") return false;
|
|
7
|
-
const ka = Object.keys(a);
|
|
8
|
-
const kb = Object.keys(b);
|
|
9
|
-
if (ka.length !== kb.length) return false;
|
|
10
|
-
return ka.every((k) => kb.includes(k) && deepEqual(a[k], b[k]));
|
|
11
|
-
}
|
|
12
|
-
var NativePoolWorker = class extends ThreadsPoolWorker {
|
|
13
|
-
name = "vitest-native";
|
|
14
|
-
reportMemory;
|
|
15
|
-
entrypoint;
|
|
16
|
-
environment;
|
|
17
|
-
recycleAfterFiles;
|
|
18
|
-
memoryLimit;
|
|
19
|
-
diagnostics;
|
|
20
|
-
filesRun = 0;
|
|
21
|
-
lastHeapUsed = 0;
|
|
22
|
-
memoryListenerAttached = false;
|
|
23
|
-
batchWarningShown = false;
|
|
24
|
-
constructor(options, native) {
|
|
25
|
-
super(options);
|
|
26
|
-
this.entrypoint = path.resolve(native.workerEntry);
|
|
27
|
-
this.environment = options.environment;
|
|
28
|
-
this.recycleAfterFiles = native.recycleAfterFiles ?? 0;
|
|
29
|
-
this.memoryLimit = native.memoryLimit ?? 0;
|
|
30
|
-
this.diagnostics = native.diagnostics ?? false;
|
|
31
|
-
this.reportMemory = this.memoryLimit > 0;
|
|
32
|
-
}
|
|
33
|
-
async start() {
|
|
34
|
-
await super.start();
|
|
35
|
-
if (this.reportMemory && !this.memoryListenerAttached) {
|
|
36
|
-
this.memoryListenerAttached = true;
|
|
37
|
-
this.on("message", (message) => {
|
|
38
|
-
if (message?.__vitest_worker_response__ && typeof message.usedMemory === "number") this.lastHeapUsed = message.usedMemory;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
send(message) {
|
|
43
|
-
if (message.type === "run" || message.type === "collect") {
|
|
44
|
-
if (this.diagnostics && !this.batchWarningShown && message.context.files.length > 1 && (this.recycleAfterFiles > 0 || this.memoryLimit > 0)) {
|
|
45
|
-
this.batchWarningShown = true;
|
|
46
|
-
console.warn(`[vitest-native] hot worker received a ${message.context.files.length}-file Vitest task; recycling thresholds apply after the task completes. Use more than one worker when strict per-file retirement is required.`);
|
|
47
|
-
}
|
|
48
|
-
this.filesRun += message.context.files.length;
|
|
49
|
-
}
|
|
50
|
-
super.send(message);
|
|
51
|
-
}
|
|
52
|
-
canReuse(task) {
|
|
53
|
-
if (this.recycleAfterFiles > 0 && this.filesRun >= this.recycleAfterFiles) return false;
|
|
54
|
-
if (this.memoryLimit > 0 && this.lastHeapUsed >= this.memoryLimit) return false;
|
|
55
|
-
const env = task.context.environment;
|
|
56
|
-
return env.name === this.environment.name && deepEqual(env.options, this.environment.options);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
/** Pool initializer for `test.pool` — keeps RN-hot workers alive across files. */
|
|
60
|
-
function nativePool(options) {
|
|
61
|
-
return {
|
|
62
|
-
name: "vitest-native",
|
|
63
|
-
createPoolWorker: (poolOptions) => new NativePoolWorker(poolOptions, options)
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
export { nativePool };
|
package/dist/pool-p54QV1dQ.cjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const require_chunk = require("./chunk-CZWwpsFl.cjs");
|
|
2
|
-
let node_path = require("node:path");
|
|
3
|
-
node_path = require_chunk.__toESM(node_path, 1);
|
|
4
|
-
let vitest_node = require("vitest/node");
|
|
5
|
-
//#region src/native/pool.ts
|
|
6
|
-
function deepEqual(a, b) {
|
|
7
|
-
if (a === b) return true;
|
|
8
|
-
if (a == null || b == null || typeof a !== "object" || typeof b !== "object") return false;
|
|
9
|
-
const ka = Object.keys(a);
|
|
10
|
-
const kb = Object.keys(b);
|
|
11
|
-
if (ka.length !== kb.length) return false;
|
|
12
|
-
return ka.every((k) => kb.includes(k) && deepEqual(a[k], b[k]));
|
|
13
|
-
}
|
|
14
|
-
var NativePoolWorker = class extends vitest_node.ThreadsPoolWorker {
|
|
15
|
-
name = "vitest-native";
|
|
16
|
-
reportMemory;
|
|
17
|
-
entrypoint;
|
|
18
|
-
environment;
|
|
19
|
-
recycleAfterFiles;
|
|
20
|
-
memoryLimit;
|
|
21
|
-
diagnostics;
|
|
22
|
-
filesRun = 0;
|
|
23
|
-
lastHeapUsed = 0;
|
|
24
|
-
memoryListenerAttached = false;
|
|
25
|
-
batchWarningShown = false;
|
|
26
|
-
constructor(options, native) {
|
|
27
|
-
super(options);
|
|
28
|
-
this.entrypoint = node_path.default.resolve(native.workerEntry);
|
|
29
|
-
this.environment = options.environment;
|
|
30
|
-
this.recycleAfterFiles = native.recycleAfterFiles ?? 0;
|
|
31
|
-
this.memoryLimit = native.memoryLimit ?? 0;
|
|
32
|
-
this.diagnostics = native.diagnostics ?? false;
|
|
33
|
-
this.reportMemory = this.memoryLimit > 0;
|
|
34
|
-
}
|
|
35
|
-
async start() {
|
|
36
|
-
await super.start();
|
|
37
|
-
if (this.reportMemory && !this.memoryListenerAttached) {
|
|
38
|
-
this.memoryListenerAttached = true;
|
|
39
|
-
this.on("message", (message) => {
|
|
40
|
-
if (message?.__vitest_worker_response__ && typeof message.usedMemory === "number") this.lastHeapUsed = message.usedMemory;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
send(message) {
|
|
45
|
-
if (message.type === "run" || message.type === "collect") {
|
|
46
|
-
if (this.diagnostics && !this.batchWarningShown && message.context.files.length > 1 && (this.recycleAfterFiles > 0 || this.memoryLimit > 0)) {
|
|
47
|
-
this.batchWarningShown = true;
|
|
48
|
-
console.warn(`[vitest-native] hot worker received a ${message.context.files.length}-file Vitest task; recycling thresholds apply after the task completes. Use more than one worker when strict per-file retirement is required.`);
|
|
49
|
-
}
|
|
50
|
-
this.filesRun += message.context.files.length;
|
|
51
|
-
}
|
|
52
|
-
super.send(message);
|
|
53
|
-
}
|
|
54
|
-
canReuse(task) {
|
|
55
|
-
if (this.recycleAfterFiles > 0 && this.filesRun >= this.recycleAfterFiles) return false;
|
|
56
|
-
if (this.memoryLimit > 0 && this.lastHeapUsed >= this.memoryLimit) return false;
|
|
57
|
-
const env = task.context.environment;
|
|
58
|
-
return env.name === this.environment.name && deepEqual(env.options, this.environment.options);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
/** Pool initializer for `test.pool` — keeps RN-hot workers alive across files. */
|
|
62
|
-
function nativePool(options) {
|
|
63
|
-
return {
|
|
64
|
-
name: "vitest-native",
|
|
65
|
-
createPoolWorker: (poolOptions) => new NativePoolWorker(poolOptions, options)
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
exports.nativePool = nativePool;
|