@jskit-ai/database-runtime-postgres 0.1.256 → 0.1.258

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@jskit-ai/database-runtime-postgres",
3
- "version": "0.1.256",
3
+ "version": "0.1.258",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "test": "node --test --test-concurrency=1"
6
+ "test": "jskit test"
7
7
  },
8
8
  "exports": {
9
9
  "./client": "./src/client/index.js",
@@ -12,11 +12,11 @@
12
12
  "./shared/dialect": "./src/shared/dialect.js"
13
13
  },
14
14
  "dependencies": {
15
- "@jskit-ai/database-runtime": "0.1.259",
15
+ "@jskit-ai/database-runtime": "0.1.261",
16
16
  "pg": "^8.13.1"
17
17
  },
18
18
  "peerDependencies": {
19
- "@jskit-ai/kernel": "0.2.10"
19
+ "@jskit-ai/kernel": "0.2.12"
20
20
  },
21
21
  "jskit": {
22
22
  "kind": "runtime",
@@ -53,6 +53,18 @@ dialect. `example/scripts/prepare-database.js` is the portable
53
53
  migrate-then-seed entrypoint for managed sessions and deployments.
54
54
  `example/.env.example` names the five connection values without a secret.
55
55
 
56
+ Tests get their own databases from
57
+ `@jskit-ai/database-runtime/server/testDatabases`. The `test` script runs
58
+ `jskit test --databases`: each Node test file running at once gets a copy of
59
+ `TEST_DB_NAME`, created from `<TEST_DB_NAME>_snapshot`, a database the
60
+ migrations are replayed into once and again only when a migration changes.
61
+ `example/tests/e2e/databases.js` is the browser run's `prepare` module for
62
+ `browserTestConfig({ prepare: "tests/e2e/databases.js" })` from
63
+ `@jskit-ai/jskit-catalog/browser-tests`: each Playwright worker's server gets
64
+ its own seeded copy of `BROWSER_TEST_DB_NAME`. The database user needs
65
+ `CREATEDB`; without it, Node test files run one at a time on the connected
66
+ database.
67
+
56
68
  `example/.github/workflows/verify.yml` is a normal app-owned CI workflow with
57
69
  exactly one database service: `postgres` (`postgres:17`, `POSTGRES_*`
58
70
  variables, port `5432`, a `pg_isready` health check). Copy it whole from this
@@ -5,9 +5,10 @@
5
5
  "db:prepare": "node ./scripts/prepare-database.js",
6
6
  "db:migrate": "knex --knexfile ./knexfile.js migrate:latest",
7
7
  "db:migrate:rollback": "knex --knexfile ./knexfile.js migrate:rollback",
8
- "db:migrate:status": "knex --knexfile ./knexfile.js migrate:list"
8
+ "db:migrate:status": "knex --knexfile ./knexfile.js migrate:list",
9
+ "test": "jskit test --databases"
9
10
  },
10
11
  "dependencies": {
11
- "@jskit-ai/database-runtime-postgres": "0.1.256"
12
+ "@jskit-ai/database-runtime-postgres": "0.1.258"
12
13
  }
13
14
  }
@@ -0,0 +1,25 @@
1
+ import { prepareTestDatabases } from "@jskit-ai/database-runtime/server/testDatabases";
2
+ import knexConfig from "../../knexfile.js";
3
+
4
+ // The browser run's `prepare` module: `browserTestConfig({ prepare: "tests/e2e/databases.js" })` in
5
+ // playwright.config.mjs runs it once, before the servers start. Every Playwright worker gets its own copy of
6
+ // BROWSER_TEST_DB_NAME (`<name>`, `<name>_1`, ...), created from the snapshot database of the current migrations with
7
+ // CREATE DATABASE ... TEMPLATE, then seeded; the normal and disposable TEST_DB_NAME databases are refused. The database
8
+ // user needs CREATEDB.
9
+
10
+ /** The fixtures the specs rely on, including any migration-owned baseline rows the app needs. */
11
+ async function seed(transaction) {
12
+ await transaction("fixtures").insert({ id: 1, label: "Browser fixture" });
13
+ }
14
+
15
+ export default async function prepareBrowserDatabases({ workers }) {
16
+ const { databases, summary } = await prepareTestDatabases({
17
+ knexConfig,
18
+ environment: process.env,
19
+ variable: "BROWSER_TEST_DB_NAME",
20
+ count: workers,
21
+ seed
22
+ });
23
+ console.log(`[browser-tests] ${summary}.`);
24
+ return databases.map((database) => ({ DB_NAME: database }));
25
+ }