neon-testing 2.2.0 → 2.2.1-beta.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/README.md +139 -37
- package/dist/browser-empty.d.ts.map +1 -1
- package/dist/browser-empty.js.map +1 -1
- package/dist/index.d.ts +45 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -22
- package/dist/index.js.map +1 -1
- package/dist/singleton.d.ts.map +1 -1
- package/dist/singleton.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js.map +1 -1
- package/dist/vitest-setup.d.ts.map +1 -1
- package/dist/vitest-setup.js.map +1 -1
- package/package.json +17 -13
package/README.md
CHANGED
|
@@ -28,12 +28,14 @@ Each test file runs against its own isolated PostgreSQL database (Neon branch),
|
|
|
28
28
|
|
|
29
29
|
### Test isolation
|
|
30
30
|
|
|
31
|
-
Tests in the same file share a single database instance (Neon branch). This means test files are fully isolated from each other, but individual tests within a file are intentionally not isolated.
|
|
32
|
-
|
|
33
|
-
This works because Vitest runs test files in [parallel](https://vitest.dev/guide/parallelism.html), while tests within each file run sequentially.
|
|
31
|
+
Tests in the same file share a single database instance (Neon branch). This means test files are fully isolated from each other, but individual tests within a file are intentionally not isolated. This works because Vitest runs test files in [parallel](https://vitest.dev/guide/parallelism.html), while tests within each file run sequentially.
|
|
34
32
|
|
|
35
33
|
If you prefer individual tests to be isolated, you can [reset the database](examples/isolated.test.ts) in a `beforeEach` lifecycle hook.
|
|
36
34
|
|
|
35
|
+
### Automatic cleanup
|
|
36
|
+
|
|
37
|
+
Test branches are automatically deleted after your tests complete. As a safety net, branches also expire after 10 minutes by default to handle interrupted or failed test runs. This dual approach minimizes costs while protecting against edge cases like crashed processes or CI failures. Both behaviors can be customized through the `deleteBranch` and `expiresIn` options.
|
|
38
|
+
|
|
37
39
|
## Quick start
|
|
38
40
|
|
|
39
41
|
### Prerequisites
|
|
@@ -57,8 +59,8 @@ import { Pool } from "@neondatabase/serverless";
|
|
|
57
59
|
|
|
58
60
|
// Enable Neon test branch for this test file
|
|
59
61
|
makeNeonTesting({
|
|
60
|
-
apiKey:
|
|
61
|
-
projectId:
|
|
62
|
+
apiKey: process.env.NEON_API_KEY!,
|
|
63
|
+
projectId: process.env.NEON_PROJECT_ID!,
|
|
62
64
|
// Recommended for Neon WebSocket drivers to automatically close connections
|
|
63
65
|
autoCloseWebSockets: true,
|
|
64
66
|
})();
|
|
@@ -74,6 +76,8 @@ test("database operations", async () => {
|
|
|
74
76
|
});
|
|
75
77
|
```
|
|
76
78
|
|
|
79
|
+
Source: [`examples/minimal.test.ts`](examples/minimal.test.ts)
|
|
80
|
+
|
|
77
81
|
### Recommended usage
|
|
78
82
|
|
|
79
83
|
#### 1. Plugin setup
|
|
@@ -90,23 +94,25 @@ export default defineConfig({
|
|
|
90
94
|
});
|
|
91
95
|
```
|
|
92
96
|
|
|
93
|
-
This plugin is recommended but not required. Without it, tests might accidentally use your existing `DATABASE_URL` (from `.env` files or environment variables) instead of the isolated test databases that Neon Testing creates. This can happen if you forget to call `
|
|
97
|
+
This plugin is recommended but not required. Without it, tests might accidentally use your existing `DATABASE_URL` (from `.env` files or environment variables) instead of the isolated test databases that Neon Testing creates. This can happen if you forget to call `neonTesting()` in a test file where database writes happen.
|
|
94
98
|
|
|
95
99
|
#### 2. Configuration
|
|
96
100
|
|
|
97
101
|
Use the `makeNeonTesting` factory to generate a lifecycle function for your tests.
|
|
98
102
|
|
|
99
103
|
```ts
|
|
100
|
-
//
|
|
104
|
+
// neon-testing.ts
|
|
101
105
|
import { makeNeonTesting } from "neon-testing";
|
|
102
106
|
|
|
103
107
|
// Export a configured lifecycle function to use in test files
|
|
104
|
-
export const
|
|
105
|
-
apiKey:
|
|
106
|
-
projectId:
|
|
108
|
+
export const neonTesting = makeNeonTesting({
|
|
109
|
+
apiKey: process.env.NEON_API_KEY!,
|
|
110
|
+
projectId: process.env.NEON_PROJECT_ID!,
|
|
107
111
|
});
|
|
108
112
|
```
|
|
109
113
|
|
|
114
|
+
Source: [`examples/neon-testing.ts`](examples/neon-testing.ts)
|
|
115
|
+
|
|
110
116
|
#### 3. Enable database testing
|
|
111
117
|
|
|
112
118
|
Then call the exported test lifecycle function in the test files where you need database access.
|
|
@@ -114,11 +120,11 @@ Then call the exported test lifecycle function in the test files where you need
|
|
|
114
120
|
```ts
|
|
115
121
|
// recommended.test.ts
|
|
116
122
|
import { expect, test } from "vitest";
|
|
117
|
-
import {
|
|
123
|
+
import { neonTesting } from "./neon-testing";
|
|
118
124
|
import { Pool } from "@neondatabase/serverless";
|
|
119
125
|
|
|
120
126
|
// Enable Neon test branch for this test file
|
|
121
|
-
|
|
127
|
+
neonTesting({
|
|
122
128
|
// Recommended for Neon WebSocket drivers to automatically close connections
|
|
123
129
|
autoCloseWebSockets: true,
|
|
124
130
|
});
|
|
@@ -134,11 +140,13 @@ test("database operations", async () => {
|
|
|
134
140
|
});
|
|
135
141
|
```
|
|
136
142
|
|
|
143
|
+
Source: [`examples/recommended.test.ts`](examples/recommended.test.ts)
|
|
144
|
+
|
|
137
145
|
## Drivers
|
|
138
146
|
|
|
139
147
|
This library works with any database driver that supports Neon Postgres and Vitest. The examples below demonstrate connection management, transaction support, and test isolation patterns for some popular drivers.
|
|
140
148
|
|
|
141
|
-
**IMPORTANT:** For [Neon WebSocket drivers](https://neon.com/docs/serverless/serverless-driver), enable `autoCloseWebSockets` in your `makeNeonTesting()` or `
|
|
149
|
+
**IMPORTANT:** For [Neon WebSocket drivers](https://neon.com/docs/serverless/serverless-driver), enable `autoCloseWebSockets` in your `makeNeonTesting()` or `neonTesting()` configuration. This automatically closes WebSocket connections when deleting test branches, preventing connection termination errors.
|
|
142
150
|
|
|
143
151
|
### Examples
|
|
144
152
|
|
|
@@ -156,9 +164,9 @@ This library works with any database driver that supports Neon Postgres and Vite
|
|
|
156
164
|
You configure Neon Testing in two places:
|
|
157
165
|
|
|
158
166
|
- **Base settings** in `makeNeonTesting()`
|
|
159
|
-
- **Optional overrides**
|
|
167
|
+
- **Optional overrides** when calling the returned function (e.g., `neonTesting()`)
|
|
160
168
|
|
|
161
|
-
Configure these in `makeNeonTesting()` and optionally override per test file
|
|
169
|
+
Configure these in `makeNeonTesting()` and optionally override per test file when calling the returned function.
|
|
162
170
|
|
|
163
171
|
```ts
|
|
164
172
|
export interface NeonTestingOptions {
|
|
@@ -203,32 +211,45 @@ export interface NeonTestingOptions {
|
|
|
203
211
|
* connections
|
|
204
212
|
*/
|
|
205
213
|
autoCloseWebSockets?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Time in seconds until the branch expires and is automatically deleted
|
|
216
|
+
* (default: 600 = 10 minutes)
|
|
217
|
+
*
|
|
218
|
+
* This provides automatic cleanup for dangling branches from interrupted or
|
|
219
|
+
* failed test runs. Set to `null` to disable automatic expiration.
|
|
220
|
+
*
|
|
221
|
+
* Must be a positive integer. Maximum 30 days (2,592,000 seconds).
|
|
222
|
+
*
|
|
223
|
+
* https://neon.com/docs/guides/branch-expiration
|
|
224
|
+
*/
|
|
225
|
+
expiresIn?: number | null;
|
|
206
226
|
}
|
|
207
227
|
```
|
|
208
228
|
|
|
209
|
-
See all available options in [NeonTestingOptions](index.ts#L31-L73).
|
|
210
|
-
|
|
211
229
|
### Base configuration
|
|
212
230
|
|
|
213
231
|
Configure the base settings in `makeNeonTesting()`:
|
|
214
232
|
|
|
215
233
|
```ts
|
|
234
|
+
// neon-testing.ts
|
|
216
235
|
import { makeNeonTesting } from "neon-testing";
|
|
217
236
|
|
|
218
|
-
export const
|
|
219
|
-
apiKey:
|
|
220
|
-
projectId:
|
|
237
|
+
export const neonTesting = makeNeonTesting({
|
|
238
|
+
apiKey: process.env.NEON_API_KEY!,
|
|
239
|
+
projectId: process.env.NEON_PROJECT_ID!,
|
|
221
240
|
});
|
|
222
241
|
```
|
|
223
242
|
|
|
224
243
|
### Override configuration
|
|
225
244
|
|
|
226
|
-
Override the base configuration in specific test files
|
|
245
|
+
Override the base configuration in specific test files when calling the function:
|
|
227
246
|
|
|
228
247
|
```ts
|
|
229
|
-
import {
|
|
248
|
+
import { neonTesting } from "./neon-testing";
|
|
230
249
|
|
|
231
|
-
|
|
250
|
+
neonTesting({
|
|
251
|
+
parentBranchId: "br-staging-123",
|
|
252
|
+
});
|
|
232
253
|
```
|
|
233
254
|
|
|
234
255
|
## Continuous integration
|
|
@@ -240,24 +261,93 @@ It's easy to run Neon integration tests in CI/CD pipelines:
|
|
|
240
261
|
- add `vitest run` to the `build` script in [package.json](https://github.com/starmode-base/template-tanstack-start/blob/83c784e164b55fd8d59c5b57b907251e5eb03de1/app/package.json#L11), or
|
|
241
262
|
- add `vitest run` to the _Build Command_ in the Vercel dashboard
|
|
242
263
|
|
|
243
|
-
##
|
|
264
|
+
## API Reference
|
|
265
|
+
|
|
266
|
+
### Main exports (`neon-testing`)
|
|
267
|
+
|
|
268
|
+
#### makeNeonTesting(options)
|
|
269
|
+
|
|
270
|
+
The factory function that creates a configured lifecycle function for your tests. See [Configuration](#configuration) for available options.
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
// neon-testing.ts
|
|
274
|
+
import { makeNeonTesting } from "neon-testing";
|
|
275
|
+
|
|
276
|
+
export const neonTesting = makeNeonTesting({
|
|
277
|
+
apiKey: process.env.NEON_API_KEY!,
|
|
278
|
+
projectId: process.env.NEON_PROJECT_ID!,
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The configured function has the following properties:
|
|
283
|
+
|
|
284
|
+
##### `.api`
|
|
285
|
+
|
|
286
|
+
Access the Neon API client to make additional API calls:
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
import { neonTesting } from "./neon-testing";
|
|
290
|
+
|
|
291
|
+
const { data } = await neonTesting.api.getProjectBranch(projectId, branchId);
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
See the [Neon API client documentation](https://neon.com/docs/reference/typescript-sdk) for all available methods.
|
|
244
295
|
|
|
245
|
-
|
|
296
|
+
##### `.deleteAllTestBranches()`
|
|
246
297
|
|
|
247
|
-
|
|
298
|
+
Deletes all test branches from your Neon project. This is useful for cleanup when tests fail unexpectedly and leave orphaned test branches.
|
|
248
299
|
|
|
249
300
|
```ts
|
|
250
|
-
import {
|
|
301
|
+
import { neonTesting } from "./neon-testing";
|
|
251
302
|
|
|
252
|
-
|
|
253
|
-
await withNeonTestBranch.deleteAllTestBranches();
|
|
303
|
+
await neonTesting.deleteAllTestBranches();
|
|
254
304
|
```
|
|
255
305
|
|
|
256
306
|
The function identifies test branches by looking for the `integration-test: true` annotation that Neon Testing automatically adds to all test branches it creates.
|
|
257
307
|
|
|
258
|
-
|
|
308
|
+
#### Accessing branch information
|
|
259
309
|
|
|
260
|
-
|
|
310
|
+
When you call the configured lifecycle function in your test files, it returns a function that gives you access to the current test branch:
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
import { neonTesting } from "./neon-testing";
|
|
314
|
+
|
|
315
|
+
const getBranch = neonTesting();
|
|
316
|
+
|
|
317
|
+
test("access branch information", () => {
|
|
318
|
+
const branch = getBranch();
|
|
319
|
+
console.log(branch.id);
|
|
320
|
+
console.log(branch.project_id);
|
|
321
|
+
console.log(branch.expires_at);
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
See the [Neon Branch API documentation](https://api-docs.neon.tech/reference/getprojectbranch) for all available properties.
|
|
326
|
+
|
|
327
|
+
### Vite plugin (`neon-testing/vite`)
|
|
328
|
+
|
|
329
|
+
The Vite plugin clears any existing `DATABASE_URL` environment variable before tests run, ensuring tests use isolated test databases.
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
import { defineConfig } from "vitest/config";
|
|
333
|
+
import { neonTesting } from "neon-testing/vite";
|
|
334
|
+
|
|
335
|
+
export default defineConfig({
|
|
336
|
+
plugins: [neonTesting()],
|
|
337
|
+
});
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Options:**
|
|
341
|
+
|
|
342
|
+
- `debug` (boolean, default: `false`) - Enable debug logging
|
|
343
|
+
|
|
344
|
+
This plugin is recommended but not required. Without it, tests might accidentally use your existing `DATABASE_URL` instead of isolated test databases.
|
|
345
|
+
|
|
346
|
+
### Utilities (`neon-testing/utils`)
|
|
347
|
+
|
|
348
|
+
#### lazySingleton(factory)
|
|
349
|
+
|
|
350
|
+
Creates a lazy singleton from a factory function. This is useful for managing database connections efficiently:
|
|
261
351
|
|
|
262
352
|
```ts
|
|
263
353
|
import { lazySingleton } from "neon-testing/utils";
|
|
@@ -287,16 +377,28 @@ Create a free Neon project at [neon.com](https://neon.com/) to test with.
|
|
|
287
377
|
|
|
288
378
|
### Release
|
|
289
379
|
|
|
290
|
-
|
|
380
|
+
Releases are published via CI when a version tag is pushed. Use these scripts to bump the version and trigger a release:
|
|
381
|
+
|
|
382
|
+
**Stable releases:**
|
|
291
383
|
|
|
292
384
|
```sh
|
|
293
|
-
bun run release:patch
|
|
294
|
-
bun run release:minor
|
|
295
|
-
bun run release:major
|
|
296
|
-
bun run release:beta
|
|
385
|
+
bun run release:patch # 1.2.3 → 1.2.4
|
|
386
|
+
bun run release:minor # 1.2.3 → 1.3.0
|
|
387
|
+
bun run release:major # 1.2.3 → 2.0.0
|
|
297
388
|
```
|
|
298
389
|
|
|
299
|
-
|
|
390
|
+
**Beta releases:**
|
|
391
|
+
|
|
392
|
+
```sh
|
|
393
|
+
bun run release:beta # Default: 1.2.3 → 1.2.4-beta.0, then 1.2.4-beta.1, etc.
|
|
394
|
+
bun run release:beta:patch # Start beta for patch: 1.2.3 → 1.2.4-beta.0
|
|
395
|
+
bun run release:beta:minor # Start beta for minor: 1.2.3 → 1.3.0-beta.0
|
|
396
|
+
bun run release:beta:major # Start beta for major: 1.2.3 → 2.0.0-beta.0
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Use `release:beta` for most beta releases. It bumps the patch version once when starting from stable, then increments the beta number for subsequent releases. Use `release:beta:minor` or `release:beta:major` only when starting a beta cycle for a larger version bump.
|
|
400
|
+
|
|
401
|
+
The scripts bump the version, create a git tag, and push to trigger CI. The command will abort if there are uncommitted changes.
|
|
300
402
|
|
|
301
403
|
## Author
|
|
302
404
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-empty.d.ts","sourceRoot":"","sources":["../browser-empty.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,SAE1B"}
|
|
1
|
+
{"version":3,"file":"browser-empty.d.ts","sourceRoot":"","sources":["../src/browser-empty.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,SAE1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-empty.js","sourceRoot":"","sources":["../browser-empty.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW;IACzB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AAC3E,CAAC"}
|
|
1
|
+
{"version":3,"file":"browser-empty.js","sourceRoot":"","sources":["../src/browser-empty.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW;IACzB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AAC3E,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://neon.com/docs/reference/typescript-sdk
|
|
3
|
+
*/
|
|
4
|
+
import { type Branch } from "@neondatabase/api-client";
|
|
1
5
|
export interface NeonTestingOptions {
|
|
2
6
|
/**
|
|
3
7
|
* The Neon API key, this is used to create and teardown test branches
|
|
@@ -40,6 +44,18 @@ export interface NeonTestingOptions {
|
|
|
40
44
|
* connections
|
|
41
45
|
*/
|
|
42
46
|
autoCloseWebSockets?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Time in seconds until the branch expires and is automatically deleted
|
|
49
|
+
* (default: 600 = 10 minutes)
|
|
50
|
+
*
|
|
51
|
+
* This provides automatic cleanup for dangling branches from interrupted or
|
|
52
|
+
* failed test runs. Set to `null` to disable automatic expiration.
|
|
53
|
+
*
|
|
54
|
+
* Must be a positive integer. Maximum 30 days (2,592,000 seconds).
|
|
55
|
+
*
|
|
56
|
+
* https://neon.com/docs/guides/branch-expiration
|
|
57
|
+
*/
|
|
58
|
+
expiresIn?: number | null;
|
|
43
59
|
}
|
|
44
60
|
/** Options for overriding test database setup (excludes apiKey) */
|
|
45
61
|
export type NeonTestingOverrides = Omit<Partial<NeonTestingOptions>, "apiKey">;
|
|
@@ -47,21 +63,38 @@ export type NeonTestingOverrides = Omit<Partial<NeonTestingOptions>, "apiKey">;
|
|
|
47
63
|
* Factory function that creates a Neon test database setup/teardown function
|
|
48
64
|
* for Vitest test suites.
|
|
49
65
|
*
|
|
50
|
-
* @param
|
|
51
|
-
* @
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
56
|
-
*
|
|
66
|
+
* @param factoryOptions - Configuration options (see {@link NeonTestingOptions})
|
|
67
|
+
* @returns A setup/teardown function with attached utilities:
|
|
68
|
+
* - `deleteAllTestBranches()` - Cleanup method to delete all test branches
|
|
69
|
+
* - `api` - Direct access to the Neon API client
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* // neon-testing.ts
|
|
74
|
+
* import { makeNeonTesting } from "neon-testing";
|
|
75
|
+
*
|
|
76
|
+
* export const neonTesting = makeNeonTesting({
|
|
77
|
+
* apiKey: "apiKey",
|
|
78
|
+
* projectId: "projectId",
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* // my-test.test.ts
|
|
85
|
+
* import { neonTesting } from "./neon-testing";
|
|
86
|
+
*
|
|
87
|
+
* const getBranch = neonTesting();
|
|
57
88
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
89
|
+
* test("my test", () => {
|
|
90
|
+
* const branch = getBranch();
|
|
91
|
+
* console.log(branch.id);
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
62
94
|
*/
|
|
63
95
|
export declare function makeNeonTesting(factoryOptions: NeonTestingOptions): {
|
|
64
|
-
(overrides?: NeonTestingOverrides):
|
|
96
|
+
(overrides?: NeonTestingOverrides): () => Branch | undefined;
|
|
65
97
|
deleteAllTestBranches: () => Promise<void>;
|
|
98
|
+
api: import("@neondatabase/api-client").Api<unknown>;
|
|
66
99
|
};
|
|
67
100
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAIL,KAAK,MAAM,EACZ,MAAM,0BAA0B,CAAC;AA0ClC,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,mEAAmE;AACnE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,kBAAkB;iBAyClD,oBAAoB;;;EA0HnC"}
|
package/dist/index.js
CHANGED
|
@@ -16,27 +16,61 @@ function createConnectionUri(connectionParameters, type) {
|
|
|
16
16
|
const hostname = type === "pooler" ? pooler_host : host;
|
|
17
17
|
return `postgresql://${role}:${password}@${hostname}/${database}?sslmode=require`;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Validates the expiresIn option
|
|
21
|
+
*/
|
|
22
|
+
function validateExpiresIn(expiresIn) {
|
|
23
|
+
if (expiresIn !== null && expiresIn !== undefined) {
|
|
24
|
+
if (!Number.isInteger(expiresIn)) {
|
|
25
|
+
throw new Error("expiresIn must be an integer");
|
|
26
|
+
}
|
|
27
|
+
if (expiresIn <= 0) {
|
|
28
|
+
throw new Error("expiresIn must be a positive integer");
|
|
29
|
+
}
|
|
30
|
+
if (expiresIn > 2592000) {
|
|
31
|
+
throw new Error("expiresIn must not exceed 30 days (2,592,000 seconds)");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
19
35
|
/**
|
|
20
36
|
* Factory function that creates a Neon test database setup/teardown function
|
|
21
37
|
* for Vitest test suites.
|
|
22
38
|
*
|
|
23
|
-
* @param
|
|
24
|
-
* @
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
29
|
-
*
|
|
39
|
+
* @param factoryOptions - Configuration options (see {@link NeonTestingOptions})
|
|
40
|
+
* @returns A setup/teardown function with attached utilities:
|
|
41
|
+
* - `deleteAllTestBranches()` - Cleanup method to delete all test branches
|
|
42
|
+
* - `api` - Direct access to the Neon API client
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* // neon-testing.ts
|
|
47
|
+
* import { makeNeonTesting } from "neon-testing";
|
|
48
|
+
*
|
|
49
|
+
* export const neonTesting = makeNeonTesting({
|
|
50
|
+
* apiKey: "apiKey",
|
|
51
|
+
* projectId: "projectId",
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
30
54
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* // my-test.test.ts
|
|
58
|
+
* import { neonTesting } from "./neon-testing";
|
|
59
|
+
*
|
|
60
|
+
* const getBranch = neonTesting();
|
|
61
|
+
*
|
|
62
|
+
* test("my test", () => {
|
|
63
|
+
* const branch = getBranch();
|
|
64
|
+
* console.log(branch.id);
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
35
67
|
*/
|
|
36
68
|
export function makeNeonTesting(factoryOptions) {
|
|
69
|
+
// Validate factory options
|
|
70
|
+
validateExpiresIn(factoryOptions.expiresIn);
|
|
37
71
|
const apiClient = createApiClient({ apiKey: factoryOptions.apiKey });
|
|
38
72
|
/**
|
|
39
|
-
* Delete all test branches
|
|
73
|
+
* Delete all test branches (branches with the "integration-test: true" annotation)
|
|
40
74
|
*/
|
|
41
75
|
async function deleteAllTestBranches() {
|
|
42
76
|
const { data } = await apiClient.listProjectBranches({
|
|
@@ -49,13 +83,29 @@ export function makeNeonTesting(factoryOptions) {
|
|
|
49
83
|
}
|
|
50
84
|
}
|
|
51
85
|
}
|
|
52
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Setup/teardown function for Vitest test suites
|
|
88
|
+
*
|
|
89
|
+
* Registers Vitest lifecycle hooks that:
|
|
90
|
+
* - Create an isolated test branch from your parent branch
|
|
91
|
+
* - Set `DATABASE_URL` environment variable to the test branch connection URI
|
|
92
|
+
* - Automatically delete the test branch after tests complete (unless `deleteBranch: false`)
|
|
93
|
+
* - Automatically expire branches after 10 minutes for cleanup (unless `expiresIn: null`)
|
|
94
|
+
*
|
|
95
|
+
* @param overrides - Optional overrides for the factory options
|
|
96
|
+
* @returns A function that provides access to the current Neon branch object
|
|
97
|
+
*/
|
|
98
|
+
const neonTesting = (
|
|
53
99
|
/** Override any factory options except apiKey */
|
|
54
100
|
overrides) => {
|
|
101
|
+
// Validate overrides
|
|
102
|
+
if (overrides?.expiresIn !== undefined) {
|
|
103
|
+
validateExpiresIn(overrides.expiresIn);
|
|
104
|
+
}
|
|
55
105
|
// Merge factory options with overrides
|
|
56
106
|
const options = { ...factoryOptions, ...overrides };
|
|
57
|
-
// Each test file gets its own branch
|
|
58
|
-
let
|
|
107
|
+
// Each test file gets its own branch and database client
|
|
108
|
+
let branch;
|
|
59
109
|
// List of tracked Neon WebSocket connections
|
|
60
110
|
const neonSockets = new Set();
|
|
61
111
|
// Custom WebSocket constructor that tracks Neon WebSocket connections
|
|
@@ -74,18 +124,24 @@ export function makeNeonTesting(factoryOptions) {
|
|
|
74
124
|
* @returns The connection URI for the new branch
|
|
75
125
|
*/
|
|
76
126
|
async function createBranch() {
|
|
127
|
+
// Calculate expiration timestamp if expiresIn is set
|
|
128
|
+
const expiresIn = options.expiresIn === undefined ? 600 : options.expiresIn; // Default: 10 minutes
|
|
129
|
+
const expiresAt = expiresIn !== null
|
|
130
|
+
? new Date(Date.now() + expiresIn * 1000).toISOString()
|
|
131
|
+
: undefined;
|
|
77
132
|
const { data } = await apiClient.createProjectBranch(options.projectId, {
|
|
78
133
|
branch: {
|
|
79
134
|
name: `test/${crypto.randomUUID()}`,
|
|
80
135
|
parent_id: options.parentBranchId,
|
|
81
136
|
init_source: options.schemaOnly ? "schema-only" : undefined,
|
|
137
|
+
expires_at: expiresAt,
|
|
82
138
|
},
|
|
83
139
|
endpoints: [{ type: EndpointType.ReadWrite }],
|
|
84
140
|
annotation_value: {
|
|
85
141
|
"integration-test": "true",
|
|
86
142
|
},
|
|
87
143
|
});
|
|
88
|
-
|
|
144
|
+
branch = data.branch;
|
|
89
145
|
const [connectionUri] = data.connection_uris ?? [];
|
|
90
146
|
if (!connectionUri) {
|
|
91
147
|
throw new Error("No connection URI found");
|
|
@@ -96,11 +152,11 @@ export function makeNeonTesting(factoryOptions) {
|
|
|
96
152
|
* Delete the test branch
|
|
97
153
|
*/
|
|
98
154
|
async function deleteBranch() {
|
|
99
|
-
if (!
|
|
155
|
+
if (!branch?.id) {
|
|
100
156
|
throw new Error("No branch to delete");
|
|
101
157
|
}
|
|
102
|
-
await apiClient.deleteProjectBranch(options.projectId,
|
|
103
|
-
|
|
158
|
+
await apiClient.deleteProjectBranch(options.projectId, branch.id);
|
|
159
|
+
branch = undefined;
|
|
104
160
|
}
|
|
105
161
|
beforeAll(async () => {
|
|
106
162
|
process.env.DATABASE_URL = await withRetry(createBranch, {
|
|
@@ -126,10 +182,17 @@ export function makeNeonTesting(factoryOptions) {
|
|
|
126
182
|
await deleteBranch();
|
|
127
183
|
}
|
|
128
184
|
});
|
|
185
|
+
/**
|
|
186
|
+
* Return the Neon branch object
|
|
187
|
+
*
|
|
188
|
+
* @returns The Neon branch object
|
|
189
|
+
*/
|
|
190
|
+
return () => branch;
|
|
129
191
|
};
|
|
130
|
-
// Attach
|
|
131
|
-
|
|
132
|
-
|
|
192
|
+
// Attach utilities
|
|
193
|
+
neonTesting.deleteAllTestBranches = deleteAllTestBranches;
|
|
194
|
+
neonTesting.api = apiClient;
|
|
195
|
+
return neonTesting;
|
|
133
196
|
}
|
|
134
197
|
/**
|
|
135
198
|
* Error handler: Suppress Neon WebSocket "Connection terminated unexpectedly"
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,eAAe,EACf,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,eAAe,EACf,YAAY,GAGb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QA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,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;gBAE3D,SAAS;YACX,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC7D,CAAC"}
|
package/dist/singleton.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../singleton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAM1D"}
|
|
1
|
+
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../src/singleton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAM1D"}
|
package/dist/singleton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.js","sourceRoot":"","sources":["../singleton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,aAAa,CAAI,OAAgB;IAC/C,IAAI,QAAuB,CAAC;IAC5B,OAAO,GAAG,EAAE;QACV,QAAQ,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"singleton.js","sourceRoot":"","sources":["../src/singleton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,aAAa,CAAI,OAAgB;IAC/C,IAAI,QAAuB,CAAC;IAC5B,OAAO,GAAG,EAAE;QACV,QAAQ,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,WAAW,wBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,WAAW,wBAAkB,CAAC"}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../vite-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,GAAE;IACP;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACZ,GACL,MAAM,CAyBR"}
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,GAAE;IACP;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACZ,GACL,MAAM,CAyBR"}
|
package/dist/vite-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,UAOI,EAAE;IAEN,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,wEAAwE;QACxE,iCAAiC;QACjC,OAAO,EAAE,MAAM;QACf,MAAM,CAAC,IAAI;YACT,MAAM,SAAS,GAAG,aAAa,CAC7B,IAAI,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAC9C,CAAC;YAEF,OAAO;gBACL,IAAI,EAAE;oBACJ,mEAAmE;oBACnE,UAAU,EAAE,KAAK,CAAC,IAAI,CACpB,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CACvD;oBACD,GAAG,EAAE;wBACH,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG;wBACjB,kBAAkB,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;qBACrD;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,UAOI,EAAE;IAEN,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,wEAAwE;QACxE,iCAAiC;QACjC,OAAO,EAAE,MAAM;QACf,MAAM,CAAC,IAAI;YACT,MAAM,SAAS,GAAG,aAAa,CAC7B,IAAI,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAC9C,CAAC;YAEF,OAAO;gBACL,IAAI,EAAE;oBACJ,mEAAmE;oBACnE,UAAU,EAAE,KAAK,CAAC,IAAI,CACpB,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CACvD;oBACD,GAAG,EAAE;wBACH,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG;wBACjB,kBAAkB,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;qBACrD;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-setup.d.ts","sourceRoot":"","sources":["../vitest-setup.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,QAAQ,oBAAqB,CAAC;AACpC,QAAA,MAAM,OAAO,SAA4C,CAAC"}
|
|
1
|
+
{"version":3,"file":"vitest-setup.d.ts","sourceRoot":"","sources":["../src/vitest-setup.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,QAAQ,oBAAqB,CAAC;AACpC,QAAA,MAAM,OAAO,SAA4C,CAAC"}
|
package/dist/vitest-setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-setup.js","sourceRoot":"","sources":["../vitest-setup.ts"],"names":[],"mappings":";AAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,MAAM,CAAC;AAE1D,IAAI,QAAQ,EAAE,CAAC;IACb,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,EAAE,CAAC;QACxC,OAAO,CAAC,KAAK,CACX,mEAAmE,CACpE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAClC,CAAC"}
|
|
1
|
+
{"version":3,"file":"vitest-setup.js","sourceRoot":"","sources":["../src/vitest-setup.ts"],"names":[],"mappings":";AAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,MAAM,CAAC;AAE1D,IAAI,QAAQ,EAAE,CAAC;IACb,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,EAAE,CAAC;QACxC,OAAO,CAAC,KAAK,CACX,mEAAmE,CACpE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neon-testing",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1-beta.1",
|
|
4
4
|
"description": "A Vitest utility for seamless integration tests with Neon Postgres",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -32,18 +32,20 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"dev": "tsc --watch",
|
|
36
|
-
"build": "rm -rf dist && tsc",
|
|
35
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
36
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && tsc && prettier --check . && vitest run",
|
|
37
37
|
"format": "prettier --write .",
|
|
38
38
|
"test": "vitest",
|
|
39
39
|
"clean:soft": "rm -rf node_modules dist && bun install",
|
|
40
40
|
"clean:hard": "rm -rf node_modules dist bun.lock && bun install",
|
|
41
|
-
"
|
|
42
|
-
"release:
|
|
43
|
-
"release:
|
|
44
|
-
"release:
|
|
45
|
-
"release:beta": "bun
|
|
46
|
-
"
|
|
41
|
+
"release:patch": "bun pm version patch",
|
|
42
|
+
"release:minor": "bun pm version minor",
|
|
43
|
+
"release:major": "bun pm version major",
|
|
44
|
+
"release:beta": "bun pm version prerelease --preid=beta",
|
|
45
|
+
"release:beta:patch": "bun pm version prepatch --preid=beta",
|
|
46
|
+
"release:beta:minor": "bun pm version preminor --preid=beta",
|
|
47
|
+
"release:beta:major": "bun pm version premajor --preid=beta",
|
|
48
|
+
"postversion": "git push --follow-tags"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
51
|
"@neondatabase/api-client": "^2.2.0"
|
|
@@ -54,15 +56,17 @@
|
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
58
|
"@neondatabase/serverless": "^1.0.2",
|
|
59
|
+
"@types/pg": "^8.15.6",
|
|
57
60
|
"dotenv": "^17.2.3",
|
|
58
|
-
"drizzle-orm": "^0.44.
|
|
61
|
+
"drizzle-orm": "^0.44.7",
|
|
59
62
|
"pg": "^8.16.3",
|
|
60
63
|
"postgres": "^3.4.7",
|
|
61
|
-
"prettier": "^3.
|
|
64
|
+
"prettier": "^3.7.1",
|
|
65
|
+
"tiny-invariant": "^1.3.3",
|
|
62
66
|
"typescript": "^5.9.3",
|
|
63
|
-
"vite": "^7.
|
|
67
|
+
"vite": "^7.2.4",
|
|
64
68
|
"vite-tsconfig-paths": "^5.1.4",
|
|
65
|
-
"vitest": "^4.0.
|
|
69
|
+
"vitest": "^4.0.14"
|
|
66
70
|
},
|
|
67
71
|
"browser": {
|
|
68
72
|
"./dist/vite-plugin.js": "./dist/browser-empty.js"
|