neon-testing 2.0.0 → 2.0.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/index.ts CHANGED
@@ -9,6 +9,8 @@ import {
9
9
  import { afterAll, beforeAll } from "vitest";
10
10
  import { neonConfig } from "@neondatabase/serverless";
11
11
 
12
+ export * from "./utils";
13
+
12
14
  /**
13
15
  * Creates a PostgreSQL connection URI from connection parameters
14
16
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon-testing",
3
- "version": "2.0.0",
3
+ "version": "2.0.1-beta.1",
4
4
  "description": "A Vitest utility for seamless integration tests with Neon Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -15,19 +15,33 @@
15
15
  "bugs": "https://github.com/starmode-base/neon-testing/issues",
16
16
  "type": "module",
17
17
  "exports": {
18
- ".": "./index.ts",
19
- "./utils": "./singleton.ts"
18
+ ".": {
19
+ "types": "./index.ts",
20
+ "import": "./index.ts",
21
+ "default": "./index.ts"
22
+ },
23
+ "./utils": {
24
+ "types": "./utils.ts",
25
+ "import": "./utils.ts",
26
+ "default": "./utils.ts"
27
+ }
20
28
  },
21
29
  "files": [
22
30
  "index.ts",
23
- "singleton.ts"
31
+ "utils.ts",
32
+ "singleton.ts",
33
+ "vite-plugin.ts",
34
+ "vitest-setup.ts"
24
35
  ],
25
36
  "scripts": {
26
37
  "test": "vitest",
27
38
  "format": "prettier --write .",
28
- "release": "bun publish",
29
- "prepublishOnly": "git diff-index --quiet HEAD || (echo 'Error: You have uncommitted changes' && exit 1) && tsc && vitest run && prettier --check .",
30
- "postpublish": "git tag v$(bun -p \"require('./package.json').version\") && git push --tags"
39
+ "release:patch": "bun pm version patch && bun publish --tag latest",
40
+ "release:minor": "bun pm version minor && bun publish --tag latest",
41
+ "release:major": "bun pm version major && bun publish --tag latest",
42
+ "release:beta": "bun pm version prerelease --preid=beta && bun publish --tag beta",
43
+ "prepublishOnly": "tsc && vitest run && prettier --check .",
44
+ "postpublish": "git push --tags"
31
45
  },
32
46
  "dependencies": {
33
47
  "@neondatabase/api-client": "^2.2.0"
package/utils.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { lazySingleton } from "./singleton";
2
+ export { neonTesting } from "./vite-plugin";
package/vite-plugin.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import type { Plugin, UserConfig } from "vite";
3
+
4
+ export function neonTesting() {
5
+ return {
6
+ name: "neon-testing-plugin",
7
+ enforce: "pre",
8
+ config(user: any) {
9
+ const setupPath = fileURLToPath(
10
+ new URL("./vitest-setup.ts", import.meta.url),
11
+ );
12
+
13
+ const setup = new Set([...(user.test?.setupFiles ?? []), setupPath]);
14
+
15
+ return {
16
+ test: {
17
+ setupFiles: Array.from(setup),
18
+ },
19
+ };
20
+ },
21
+ } satisfies Plugin;
22
+ }
@@ -0,0 +1,12 @@
1
+ const isVitest =
2
+ process.env.VITEST === "true" || !!process.env.VITEST_WORKER_ID;
3
+
4
+ if (isVitest) {
5
+ if (process.env.DATABASE_URL) {
6
+ console.warn(
7
+ "[neon-testing] Clearing existing DATABASE_URL in test environment",
8
+ );
9
+ }
10
+
11
+ delete process.env.DATABASE_URL;
12
+ }