@kasperpeulen/vitest-plugin-nextjs 0.0.0-alpha.0 → 0.1.0-alpha.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/README.md +249 -2
- package/dist/_virtual/_rolldown/runtime.js +14 -0
- package/dist/action-ids.d.ts +18 -0
- package/dist/action-ids.js +44 -0
- package/dist/adapter.d.ts +8 -0
- package/dist/adapter.js +12 -0
- package/dist/app-requests.d.ts +63 -0
- package/dist/app-requests.js +253 -0
- package/dist/browser-context.d.ts +24 -0
- package/dist/browser-context.js +157 -0
- package/dist/build-output.d.ts +68 -0
- package/dist/build-output.js +216 -0
- package/dist/build.d.ts +26 -0
- package/dist/build.js +39 -0
- package/dist/built-files.d.ts +9 -0
- package/dist/built-files.js +22 -0
- package/dist/cache.d.ts +44 -0
- package/dist/cache.js +99 -0
- package/dist/client-components.d.ts +3 -0
- package/dist/client-components.js +4 -0
- package/dist/client-file-key.d.ts +5 -0
- package/dist/client-file-key.js +5 -0
- package/dist/client-files.d.ts +83 -0
- package/dist/client-files.js +186 -0
- package/dist/client-graph.d.ts +94 -0
- package/dist/client-graph.js +266 -0
- package/dist/client-modules.d.ts +10 -0
- package/dist/client-modules.js +43 -0
- package/dist/client.d.ts +42 -0
- package/dist/client.js +263 -0
- package/dist/commonjs.d.ts +44 -0
- package/dist/commonjs.js +111 -0
- package/dist/compat/browser/client.d.ts +19 -0
- package/dist/compat/browser/client.js +13 -0
- package/dist/compat/build.d.ts +145 -0
- package/dist/compat/build.js +149 -0
- package/dist/compat/checks.d.ts +16 -0
- package/dist/compat/checks.js +148 -0
- package/dist/compat/patches.d.ts +13 -0
- package/dist/compat/patches.js +30 -0
- package/dist/compat/paths.d.ts +74 -0
- package/dist/compat/paths.js +160 -0
- package/dist/compat/rsc/handlers.d.ts +2 -0
- package/dist/compat/rsc/handlers.js +2 -0
- package/dist/compat/rsc/prerender.d.ts +10 -0
- package/dist/compat/rsc/prerender.js +9 -0
- package/dist/compat/server/headers.d.ts +3 -0
- package/dist/compat/server/headers.js +3 -0
- package/dist/compat/ssr/build-output.d.ts +4 -0
- package/dist/compat/ssr/build-output.js +3 -0
- package/dist/compat/ssr/cache.d.ts +6 -0
- package/dist/compat/ssr/cache.js +6 -0
- package/dist/compat/ssr/handler.d.ts +8 -0
- package/dist/compat/ssr/handler.js +8 -0
- package/dist/compat/ssr/node-server.d.ts +5 -0
- package/dist/compat/ssr/node-server.js +4 -0
- package/dist/compat/ssr/render-errors.d.ts +4 -0
- package/dist/compat/ssr/render-errors.js +4 -0
- package/dist/compat/ssr/senders.d.ts +6 -0
- package/dist/compat/ssr/senders.js +6 -0
- package/dist/compat/types.d.ts +8 -0
- package/dist/compat/types.js +1 -0
- package/dist/compile.d.ts +31 -0
- package/dist/compile.js +140 -0
- package/dist/disk.d.ts +16 -0
- package/dist/disk.js +13 -0
- package/dist/document-loads.d.ts +15 -0
- package/dist/document-loads.js +53 -0
- package/dist/document.d.ts +79 -0
- package/dist/document.js +328 -0
- package/dist/downloads.d.ts +15 -0
- package/dist/downloads.js +71 -0
- package/dist/esm-require.d.ts +11 -0
- package/dist/esm-require.js +32 -0
- package/dist/fast-crypto/index.js +1093 -0
- package/dist/fast-crypto.d.ts +20 -0
- package/dist/fast-crypto.js +151 -0
- package/dist/flight.d.ts +19 -0
- package/dist/flight.js +42 -0
- package/dist/form-submission.d.ts +15 -0
- package/dist/form-submission.js +27 -0
- package/dist/from-page.d.ts +5 -0
- package/dist/from-page.js +44 -0
- package/dist/globals.d.ts +1 -0
- package/dist/globals.js +197 -0
- package/dist/host-document.d.ts +26 -0
- package/dist/host-document.js +34 -0
- package/dist/index.d.ts +280 -0
- package/dist/index.js +281 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +3 -0
- package/dist/leftovers.d.ts +11 -0
- package/dist/leftovers.js +55 -0
- package/dist/mode.d.ts +169 -0
- package/dist/mode.js +31 -0
- package/dist/node/LICENSES.md +3540 -0
- package/dist/node/assert/strict.js +29 -0
- package/dist/node/assert.js +3044 -0
- package/dist/node/buffer.js +1499 -0
- package/dist/node/child_process.js +45 -0
- package/dist/node/cluster.js +85 -0
- package/dist/node/console.js +96 -0
- package/dist/node/constants.js +495 -0
- package/dist/node/crypto.js +1388 -0
- package/dist/node/dgram.js +78 -0
- package/dist/node/diagnostics_channel.js +122 -0
- package/dist/node/dns/promises.js +129 -0
- package/dist/node/dns.js +137 -0
- package/dist/node/domain.js +43 -0
- package/dist/node/events.js +1155 -0
- package/dist/node/fs/promises.js +40 -0
- package/dist/node/fs.js +10375 -0
- package/dist/node/http.js +326 -0
- package/dist/node/http2.js +305 -0
- package/dist/node/https.js +57 -0
- package/dist/node/inspector/promises.js +66 -0
- package/dist/node/inspector.js +76 -0
- package/dist/node/module.js +205 -0
- package/dist/node/net.js +392 -0
- package/dist/node/os.js +259 -0
- package/dist/node/path/posix.js +25 -0
- package/dist/node/path/win32.js +25 -0
- package/dist/node/path.js +384 -0
- package/dist/node/perf_hooks.js +313 -0
- package/dist/node/process.js +452 -0
- package/dist/node/punycode.js +178 -0
- package/dist/node/querystring.js +934 -0
- package/dist/node/readline/promises.js +71 -0
- package/dist/node/readline.js +56 -0
- package/dist/node/repl.js +44 -0
- package/dist/node/sqlite.js +22 -0
- package/dist/node/stream/consumers.js +47 -0
- package/dist/node/stream/promises.js +6 -0
- package/dist/node/stream/web.js +52 -0
- package/dist/node/stream.js +4323 -0
- package/dist/node/string_decoder.js +276 -0
- package/dist/node/sys.js +6 -0
- package/dist/node/timers/promises.js +71 -0
- package/dist/node/timers.js +133 -0
- package/dist/node/tls.js +122 -0
- package/dist/node/trace_events.js +23 -0
- package/dist/node/tty.js +69 -0
- package/dist/node/url.js +1426 -0
- package/dist/node/util/types.js +1456 -0
- package/dist/node/util.js +4807 -0
- package/dist/node/v8.js +160 -0
- package/dist/node/vm.js +88 -0
- package/dist/node/wasi.js +16 -0
- package/dist/node/worker_threads.js +123 -0
- package/dist/node/zlib.js +1396 -0
- package/dist/node-builtins.d.ts +40 -0
- package/dist/node-builtins.js +74 -0
- package/dist/node-on-page.d.ts +46 -0
- package/dist/node-on-page.js +101 -0
- package/dist/node-platform.d.ts +36 -0
- package/dist/node-platform.js +152 -0
- package/dist/node-rendered.d.ts +21 -0
- package/dist/node-rendered.js +26 -0
- package/dist/node-server.d.ts +46 -0
- package/dist/node-server.js +193 -0
- package/dist/optimizer-cache-key.d.ts +26 -0
- package/dist/optimizer-cache-key.js +73 -0
- package/dist/own-package.d.ts +1 -0
- package/dist/own-package.js +6 -0
- package/dist/page-store.d.ts +33 -0
- package/dist/page-store.js +80 -0
- package/dist/page-timers.d.ts +22 -0
- package/dist/page-timers.js +47 -0
- package/dist/page.d.ts +112 -0
- package/dist/page.js +549 -0
- package/dist/paths.d.ts +13 -0
- package/dist/paths.js +47 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.js +995 -0
- package/dist/prerender-verdict.d.ts +8 -0
- package/dist/prerender-verdict.js +67 -0
- package/dist/project/context.d.ts +546 -0
- package/dist/project/context.js +111 -0
- package/dist/project/entries.d.ts +42 -0
- package/dist/project/entries.js +189 -0
- package/dist/project/env-worker.d.ts +1 -0
- package/dist/project/env-worker.js +9 -0
- package/dist/project/env.d.ts +36 -0
- package/dist/project/env.js +82 -0
- package/dist/project/layers.d.ts +31 -0
- package/dist/project/layers.js +150 -0
- package/dist/project/loaders.d.ts +71 -0
- package/dist/project/loaders.js +300 -0
- package/dist/project/metadata.d.ts +8 -0
- package/dist/project/metadata.js +34 -0
- package/dist/project/module-exports.d.ts +29 -0
- package/dist/project/module-exports.js +77 -0
- package/dist/project/routes.d.ts +19 -0
- package/dist/project/routes.js +92 -0
- package/dist/project/routing.d.ts +46 -0
- package/dist/project/routing.js +280 -0
- package/dist/project/transform.d.ts +8 -0
- package/dist/project/transform.js +110 -0
- package/dist/project/webpack.d.ts +46 -0
- package/dist/project/webpack.js +160 -0
- package/dist/project.d.ts +264 -0
- package/dist/project.js +58 -0
- package/dist/registry-global.d.ts +5 -0
- package/dist/registry-global.js +5 -0
- package/dist/registry.d.ts +241 -0
- package/dist/registry.js +30 -0
- package/dist/route-chunks.d.ts +13 -0
- package/dist/route-chunks.js +32 -0
- package/dist/route-lookup.d.ts +34 -0
- package/dist/route-lookup.js +207 -0
- package/dist/routes-ahead-shared.d.ts +17 -0
- package/dist/routes-ahead-shared.js +9 -0
- package/dist/routes-ahead.d.ts +10 -0
- package/dist/routes-ahead.js +54 -0
- package/dist/rsc.d.ts +19 -0
- package/dist/rsc.js +171 -0
- package/dist/server-action.d.ts +9 -0
- package/dist/server-action.js +15 -0
- package/dist/server-code.d.ts +176 -0
- package/dist/server-code.js +357 -0
- package/dist/server-in-front.d.ts +37 -0
- package/dist/server-in-front.js +90 -0
- package/dist/server-layers.d.ts +22 -0
- package/dist/server-layers.js +33 -0
- package/dist/setup-browser.d.ts +1 -0
- package/dist/setup-browser.js +8 -0
- package/dist/setup-node.d.ts +1 -0
- package/dist/setup-node.js +6 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.js +62 -0
- package/dist/speed-features.d.ts +13 -0
- package/dist/speed-features.js +95 -0
- package/dist/ssr.d.ts +70 -0
- package/dist/ssr.js +480 -0
- package/dist/static-build.d.ts +36 -0
- package/dist/static-build.js +92 -0
- package/dist/storage.d.ts +31 -0
- package/dist/storage.js +94 -0
- package/dist/styles-shared.d.ts +137 -0
- package/dist/styles-shared.js +124 -0
- package/dist/styles.d.ts +102 -0
- package/dist/styles.js +730 -0
- package/dist/stylesheet-versions.d.ts +17 -0
- package/dist/stylesheet-versions.js +43 -0
- package/dist/tester.html +10 -0
- package/dist/use-cache.d.ts +15 -0
- package/dist/use-cache.js +93 -0
- package/dist/vitest-version.d.ts +6 -0
- package/dist/vitest-version.js +12 -0
- package/package.json +125 -4
package/dist/mode.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
//#region src/mode.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* What a test run gives up for speed. `"fidelity"`, the default, gives up
|
|
4
|
+
* nothing: a test sees what a browser shows of the app, as CI is to run it.
|
|
5
|
+
* `"fast"` turns on every speed feature, for a quick feedback loop, like an
|
|
6
|
+
* agent's or a watch run's, which gives up some of that. A suite that passes
|
|
7
|
+
* in fast mode is to pass in fidelity mode too.
|
|
8
|
+
*/
|
|
9
|
+
type Mode = "fidelity" | "fast";
|
|
10
|
+
/**
|
|
11
|
+
* The speed features, each an option of `vitestPluginNext()` of its own:
|
|
12
|
+
* `true` is the faster behavior, `false` the faithful one. One that is not
|
|
13
|
+
* set follows `mode`, but for `watchDom`, which gives up nothing and is on
|
|
14
|
+
* in both modes.
|
|
15
|
+
*/
|
|
16
|
+
type SpeedOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* Experimental. The pages of a test file render in one app: the first
|
|
19
|
+
* page starts it, and every `renderServer({ url })` after it renders its
|
|
20
|
+
* page in it, from the page's Flight payload, without a page load. The
|
|
21
|
+
* first `renderServer({ url })` after the page heard of a change of a
|
|
22
|
+
* module of the browser layer starts a new app, with the modules as they
|
|
23
|
+
* are now.
|
|
24
|
+
*
|
|
25
|
+
* Gives up: a fresh page per test. Each page gets a tree, a router and
|
|
26
|
+
* caches of the router of its own, so no state of a component carries over
|
|
27
|
+
* from one test to the next. What does is the state of the modules of the
|
|
28
|
+
* app, of a package and of Next and React, as in a single-page app that
|
|
29
|
+
* never reloads. The server renders no HTML (`ssr: false`), also not of a
|
|
30
|
+
* page that the app loads itself from one of these, like after a `<form>`
|
|
31
|
+
* without a Server Action, so no preload of the HTML or its `Link` header:
|
|
32
|
+
* a test that asserts on it passes `ssr: true`, and gets a page load of its
|
|
33
|
+
* own. In development the page has no dev overlay. The status of the
|
|
34
|
+
* `response` is the one Next sets as it renders the HTML, read from the
|
|
35
|
+
* error in the Flight payload, and a page whose payload redirects loads as
|
|
36
|
+
* its target, as a browser follows the 307 of a document: but for a page
|
|
37
|
+
* that fails under a Suspense boundary, which gets the error's status,
|
|
38
|
+
* where Next has sent the 200 of its document before the error.
|
|
39
|
+
*
|
|
40
|
+
* Default: `true` in fast mode, `false` in fidelity mode.
|
|
41
|
+
*/
|
|
42
|
+
keepApp?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Experimental. A page of the kept app, one of `renderServer({ url })` or
|
|
45
|
+
* one that the app loads itself with a `GET`, is requested as Next's
|
|
46
|
+
* router requests a page, with `RSC: 1`: the server renders no HTML for
|
|
47
|
+
* it, and the page parses no document. Of the kept app only: without
|
|
48
|
+
* `keepApp` it changes nothing.
|
|
49
|
+
*
|
|
50
|
+
* Gives up: the `response` of `renderServer()` is the one of Flight,
|
|
51
|
+
* `text/x-component`, not the document's. A route handler on the way, like
|
|
52
|
+
* one that redirects to the page, sees `RSC: 1` in its request. A page
|
|
53
|
+
* that the test leaves while it loads stops rendering on the server, where
|
|
54
|
+
* the render of a document would go on: a test of a render that outlives
|
|
55
|
+
* its page passes `ssr: true`.
|
|
56
|
+
*
|
|
57
|
+
* The server handles each page once. Its status and redirects are as with
|
|
58
|
+
* `keepApp` alone: a page whose payload redirects loads as its target,
|
|
59
|
+
* with one request of Flight of the target, and the `response` is the
|
|
60
|
+
* target's, with `redirected` and the final URL. A redirect to another
|
|
61
|
+
* origin throws, as in fidelity mode.
|
|
62
|
+
*
|
|
63
|
+
* Default: `true` in fast mode, `false` in fidelity mode.
|
|
64
|
+
*/
|
|
65
|
+
flightLoads?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Experimental. Next's router prefetches nothing: not for a `<Link>` or a
|
|
68
|
+
* `<Form>`, nor for a `router.prefetch()` of the app.
|
|
69
|
+
*
|
|
70
|
+
* Gives up: a test sees no prefetch: no request of one, and no route
|
|
71
|
+
* that renders from what one got. Next prefetches in production only, so
|
|
72
|
+
* in development it gives up nothing.
|
|
73
|
+
*
|
|
74
|
+
* Default: `true` in fast mode, `false` in fidelity mode.
|
|
75
|
+
*/
|
|
76
|
+
skipPrefetch?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Experimental. The server's code runs a timeout of 0 as an immediate,
|
|
79
|
+
* like those that React separates the steps of a render with, unless the
|
|
80
|
+
* test has faked the timers.
|
|
81
|
+
*
|
|
82
|
+
* Gives up: the delay a browser adds to a timeout, at least 4 ms for one
|
|
83
|
+
* that a timeout started, five deep: also for a timeout of 0 of the app's
|
|
84
|
+
* own server code.
|
|
85
|
+
*
|
|
86
|
+
* Default: `true` in fast mode, `false` in fidelity mode.
|
|
87
|
+
*/
|
|
88
|
+
immediates?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Experimental. `expect.element()` and `expect.poll()` look again on the
|
|
91
|
+
* next change of the document, not after a growing wait: a mutation of the
|
|
92
|
+
* DOM, or an event of what changes without one, like `input` or the `load`
|
|
93
|
+
* of a stylesheet; after 5 ms for what a script sets on a property. Not
|
|
94
|
+
* with an interval of the poll's own, nor while the test's timers are fake:
|
|
95
|
+
* those poll at that interval, or at `expect.poll.interval` of the config,
|
|
96
|
+
* 5 ms where the config sets none. Else that option does not count.
|
|
97
|
+
*
|
|
98
|
+
* Gives up nothing: it changes when an assertion looks at the DOM, not
|
|
99
|
+
* what it sees. Without it, Vitest waits between the looks, after 0, 20,
|
|
100
|
+
* 50, 100, 100 and then every 500 ms, and a test sees most changes tens of
|
|
101
|
+
* milliseconds late. On an M1 Pro, the 500 tests of the notes benchmark
|
|
102
|
+
* took about 60 s without it and 26 s with it in fidelity mode, and 52 s
|
|
103
|
+
* and 17 s in fast mode.
|
|
104
|
+
*
|
|
105
|
+
* Default: `true` in both modes.
|
|
106
|
+
*/
|
|
107
|
+
watchDom?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Experimental. A page load does not ask the dev server for the versions
|
|
110
|
+
* of its modules: the page has the server's news of every change of them,
|
|
111
|
+
* and asks once as a test file starts, and as it loads a file with
|
|
112
|
+
* `"use client"` again. In a test run of Vitest only: the
|
|
113
|
+
* page of a dev server of another host, like `storybook dev`, asks at
|
|
114
|
+
* every page load.
|
|
115
|
+
*
|
|
116
|
+
* Gives up: a change that reaches the dev server through another
|
|
117
|
+
* connection than the page's, like a request of the test that changes a
|
|
118
|
+
* file, is seen once the server's news of it has arrived, which may be
|
|
119
|
+
* after the next page load. A change of a file that the tests are watched
|
|
120
|
+
* for runs the test file again.
|
|
121
|
+
*
|
|
122
|
+
* Default: `true` in fast mode, `false` in fidelity mode.
|
|
123
|
+
*/
|
|
124
|
+
cacheDevServer?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Experimental. Password hashes and key derivations cost microseconds,
|
|
127
|
+
* with the same API, for the server code in the page and the test files:
|
|
128
|
+
* PBKDF2 of `crypto.subtle`, `pbkdf2`, `scrypt` and `argon2` of
|
|
129
|
+
* `node:crypto`, and the packages bcryptjs, bcrypt, @node-rs/bcrypt,
|
|
130
|
+
* argon2, @node-rs/argon2 and the scrypt, pbkdf2 and argon2 of
|
|
131
|
+
* @noble/hashes, which Better Auth hashes with. A hash a test makes
|
|
132
|
+
* verifies in the app, and a password verifies against its own hash only.
|
|
133
|
+
* It is one SHA-256: never a password hash outside a test, and the plugin
|
|
134
|
+
* gives it to a test run of Vitest only, never to a build.
|
|
135
|
+
*
|
|
136
|
+
* Gives up: a hash made by the real algorithm, like one in a fixture, does
|
|
137
|
+
* not verify under a stand-in: bcrypt's and Argon2's throw an error that
|
|
138
|
+
* says so. See docs/nodejs-in-the-browser.md, "Fast crypto".
|
|
139
|
+
*
|
|
140
|
+
* Default: `true` in fast mode, `false` in fidelity mode.
|
|
141
|
+
*/
|
|
142
|
+
fastCrypto?: boolean;
|
|
143
|
+
};
|
|
144
|
+
/** A speed feature, by the name of its option. */
|
|
145
|
+
type SpeedFeature = keyof SpeedOptions;
|
|
146
|
+
/** Which speed features are on: `mode` and the options of the features, resolved. */
|
|
147
|
+
type SpeedFeatures = Required<SpeedOptions>;
|
|
148
|
+
/** The options of `vitestPluginNext()` that choose the speed features. */
|
|
149
|
+
type ModeOptions = SpeedOptions & {
|
|
150
|
+
/**
|
|
151
|
+
* Experimental. `"fidelity"`, a test run that gives up nothing for speed,
|
|
152
|
+
* or `"fast"`, every speed feature on: see `Mode`. An option of a feature,
|
|
153
|
+
* like `fastCrypto: false` or `skipPrefetch: true`, overrides the mode.
|
|
154
|
+
*
|
|
155
|
+
* @default in a test run of Vitest the environment variable
|
|
156
|
+
* `VITEST_PLUGIN_RSC_MODE`, `fast` or `fidelity`, else `"fidelity"`
|
|
157
|
+
*/
|
|
158
|
+
mode?: Mode;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* The speed features that `options` turn on: every one that is set as it is
|
|
162
|
+
* set, and the others as `mode` has them, all on for `"fast"` and all but
|
|
163
|
+
* `watchDom` off for `"fidelity"`. Without `mode`, `VITEST_PLUGIN_RSC_MODE`
|
|
164
|
+
* of `env` chooses it in a test run of Vitest, else it is `"fidelity"`.
|
|
165
|
+
* Throws for an unknown mode.
|
|
166
|
+
*/
|
|
167
|
+
declare function resolveSpeedFeatures(options: ModeOptions, env: Record<string, string | undefined>): SpeedFeatures;
|
|
168
|
+
//#endregion
|
|
169
|
+
export { Mode, ModeOptions, SpeedFeature, SpeedFeatures, SpeedOptions, resolveSpeedFeatures };
|
package/dist/mode.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/mode.ts
|
|
2
|
+
const inFidelityMode = {
|
|
3
|
+
keepApp: false,
|
|
4
|
+
flightLoads: false,
|
|
5
|
+
skipPrefetch: false,
|
|
6
|
+
immediates: false,
|
|
7
|
+
watchDom: true,
|
|
8
|
+
cacheDevServer: false,
|
|
9
|
+
fastCrypto: false
|
|
10
|
+
};
|
|
11
|
+
/** Every speed feature, in the order of `SpeedOptions`. */
|
|
12
|
+
const features = Object.keys(inFidelityMode);
|
|
13
|
+
const modes = ["fidelity", "fast"];
|
|
14
|
+
/**
|
|
15
|
+
* The speed features that `options` turn on: every one that is set as it is
|
|
16
|
+
* set, and the others as `mode` has them, all on for `"fast"` and all but
|
|
17
|
+
* `watchDom` off for `"fidelity"`. Without `mode`, `VITEST_PLUGIN_RSC_MODE`
|
|
18
|
+
* of `env` chooses it in a test run of Vitest, else it is `"fidelity"`.
|
|
19
|
+
* Throws for an unknown mode.
|
|
20
|
+
*/
|
|
21
|
+
function resolveSpeedFeatures(options, env) {
|
|
22
|
+
const fromEnv = env.VITEST === void 0 ? void 0 : env.VITEST_PLUGIN_RSC_MODE;
|
|
23
|
+
const mode = options.mode ?? (fromEnv || "fidelity");
|
|
24
|
+
if (!modes.includes(mode)) {
|
|
25
|
+
const source = options.mode === void 0 ? "`VITEST_PLUGIN_RSC_MODE`" : "`mode`";
|
|
26
|
+
throw new Error(`vitest-plugin-rsc: ${source} is "fidelity" or "fast", not ${JSON.stringify(mode)}.`);
|
|
27
|
+
}
|
|
28
|
+
return Object.fromEntries(features.map((feature) => [feature, options[feature] ?? (mode === "fast" || inFidelityMode[feature])]));
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { resolveSpeedFeatures };
|