supabase-test 0.4.2 → 0.4.3
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 +24 -35
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
`supabase-test` is a Supabase-optimized version of [`pgsql-test`](https://www.npmjs.com/package/pgsql-test) with Supabase defaults baked in. It provides instant, isolated PostgreSQL databases for testing with automatic transaction rollbacks, context switching, and clean seeding — configured for Supabase's local development environment. It's also great for GitHub Actions and CI/CD testing.
|
|
20
20
|
|
|
21
|
-
Explore a full working example (including GitHub Actions CI/CD) in the [`supabase-test-suite`](https://github.com/constructive-
|
|
21
|
+
Explore a full working example (including GitHub Actions CI/CD) in the [`supabase-test-suite`](https://github.com/constructive-io/supabase-test-suite) repo.
|
|
22
22
|
|
|
23
23
|
## Install
|
|
24
24
|
|
|
@@ -54,7 +54,7 @@ npm install supabase-test
|
|
|
54
54
|
* [Programmatic Seeding](#-programmatic-seeding)
|
|
55
55
|
* [CSV Seeding](#️-csv-seeding)
|
|
56
56
|
* [JSON Seeding](#️-json-seeding)
|
|
57
|
-
* [Seeding](#-
|
|
57
|
+
* [Seeding](#-pgpm-seeding)
|
|
58
58
|
7. [`getConnections() Options` ](#getconnections-options)
|
|
59
59
|
8. [Disclaimer](#disclaimer)
|
|
60
60
|
|
|
@@ -235,9 +235,9 @@ This array lets you fully customize how your test database is seeded. You can co
|
|
|
235
235
|
* [`seed.fn()`](#-programmatic-seeding) – Run JavaScript/TypeScript logic to programmatically insert data
|
|
236
236
|
* [`seed.csv()`](#️-csv-seeding) – Load tabular data from CSV files
|
|
237
237
|
* [`seed.json()`](#️-json-seeding) – Use in-memory objects as seed data
|
|
238
|
-
* [`seed.
|
|
238
|
+
* [`seed.pgpm()`](#-pgpm-seeding) – Apply a PGPM project or set of packages (compatible with sqitch)
|
|
239
239
|
|
|
240
|
-
> ✨ **Default Behavior:** If no `SeedAdapter[]` is passed,
|
|
240
|
+
> ✨ **Default Behavior:** If no `SeedAdapter[]` is passed, pgpm seeding is assumed. This makes `supabase-test` zero-config for pgpm-based projects.
|
|
241
241
|
|
|
242
242
|
This composable system allows you to mix-and-match data setup strategies for flexible, realistic, and fast database tests.
|
|
243
243
|
|
|
@@ -259,7 +259,7 @@ await db.loadCsv({ 'users': '/path/to/users.csv' });
|
|
|
259
259
|
await db.loadSql(['/path/to/schema.sql']);
|
|
260
260
|
```
|
|
261
261
|
|
|
262
|
-
> **Note:** `loadCsv()` and `
|
|
262
|
+
> **Note:** `loadCsv()` and `loadPpgm()` do not apply RLS context (PostgreSQL limitation). Use `loadJson()` or `loadSql()` for RLS-aware seeding.
|
|
263
263
|
|
|
264
264
|
### 🔌 SQL File Seeding
|
|
265
265
|
|
|
@@ -500,32 +500,32 @@ it('has loaded rows', async () => {
|
|
|
500
500
|
|
|
501
501
|
</details>
|
|
502
502
|
|
|
503
|
-
## 🚀
|
|
503
|
+
## 🚀 pgpm Seeding
|
|
504
504
|
|
|
505
505
|
**Zero Configuration (Default):**
|
|
506
506
|
```ts
|
|
507
|
-
//
|
|
507
|
+
// pgpm migrate is used automatically
|
|
508
508
|
const { db, teardown } = await getConnections();
|
|
509
509
|
```
|
|
510
510
|
|
|
511
511
|
**Adapter Pattern (Custom Path):**
|
|
512
512
|
```ts
|
|
513
513
|
const { db, teardown } = await getConnections({}, [
|
|
514
|
-
seed.
|
|
514
|
+
seed.pgpm('/path/to/your-pgpm-workspace', true) // with cache
|
|
515
515
|
]);
|
|
516
516
|
```
|
|
517
517
|
|
|
518
518
|
**Direct Load Method:**
|
|
519
519
|
```ts
|
|
520
|
-
await db.
|
|
520
|
+
await db.loadPgpm('/path/to/your-pgpm-workspace', true); // with cache
|
|
521
521
|
```
|
|
522
522
|
|
|
523
|
-
> **Note:**
|
|
523
|
+
> **Note:** pgpm deployment has its own client handling and does not apply RLS context.
|
|
524
524
|
|
|
525
525
|
<details>
|
|
526
526
|
<summary>Full example</summary>
|
|
527
527
|
|
|
528
|
-
If your project uses
|
|
528
|
+
If your project uses pgpm modules with a precompiled `pgpm.plan`, you can use `supabase-test` with **zero configuration**. Just call `getConnections()` — and it *just works*:
|
|
529
529
|
|
|
530
530
|
```ts
|
|
531
531
|
import { getConnections } from 'supabase-test';
|
|
@@ -533,50 +533,39 @@ import { getConnections } from 'supabase-test';
|
|
|
533
533
|
let db, teardown;
|
|
534
534
|
|
|
535
535
|
beforeAll(async () => {
|
|
536
|
-
({ db, teardown } = await getConnections()); //
|
|
536
|
+
({ db, teardown } = await getConnections()); // pgpm module is deployed automatically
|
|
537
537
|
});
|
|
538
538
|
```
|
|
539
539
|
|
|
540
|
-
|
|
540
|
+
pgpm uses Sqitch-compatible syntax with a TypeScript-based migration engine. By default, `supabase-test` automatically deploys any pgpm module found in the current working directory (`process.cwd()`).
|
|
541
541
|
|
|
542
|
-
To specify a custom path to your
|
|
542
|
+
To specify a custom path to your pgpm module, use `seed.pgpm()` explicitly:
|
|
543
543
|
|
|
544
544
|
```ts
|
|
545
545
|
import path from 'path';
|
|
546
546
|
import { getConnections, seed } from 'supabase-test';
|
|
547
547
|
|
|
548
|
-
const cwd = path.resolve(__dirname, '../path/to/
|
|
548
|
+
const cwd = path.resolve(__dirname, '../path/to/pgpm-workspace');
|
|
549
549
|
|
|
550
550
|
beforeAll(async () => {
|
|
551
551
|
({ db, teardown } = await getConnections({}, [
|
|
552
|
-
seed.
|
|
552
|
+
seed.pgpm(cwd)
|
|
553
553
|
]));
|
|
554
554
|
});
|
|
555
555
|
```
|
|
556
556
|
|
|
557
557
|
</details>
|
|
558
558
|
|
|
559
|
-
## Why
|
|
559
|
+
## Why PGPM's Approach?
|
|
560
560
|
|
|
561
|
-
|
|
561
|
+
pgpm provides the best of both worlds:
|
|
562
562
|
|
|
563
563
|
1. **Sqitch Compatibility**: Keep your familiar Sqitch syntax and migration approach
|
|
564
564
|
2. **TypeScript Performance**: Our TS-rewritten deployment engine delivers up to 10x faster schema deployments
|
|
565
565
|
3. **Developer Experience**: Tight feedback loops with near-instant schema setup for tests
|
|
566
566
|
4. **CI Optimization**: Dramatically reduced test suite run times with optimized deployment
|
|
567
567
|
|
|
568
|
-
By maintaining Sqitch compatibility while supercharging performance,
|
|
569
|
-
|
|
570
|
-
## Why LaunchQL's Approach?
|
|
571
|
-
|
|
572
|
-
LaunchQL provides the best of both worlds:
|
|
573
|
-
|
|
574
|
-
1. **Sqitch Compatibility**: Keep your familiar Sqitch syntax and migration approach
|
|
575
|
-
2. **TypeScript Performance**: Our TS-rewritten deployment engine delivers up to 10x faster schema deployments
|
|
576
|
-
3. **Developer Experience**: Tight feedback loops with near-instant schema setup for tests
|
|
577
|
-
4. **CI Optimization**: Dramatically reduced test suite run times with optimized deployment
|
|
578
|
-
|
|
579
|
-
By maintaining Sqitch compatibility while supercharging performance, LaunchQL enables you to keep your existing migration patterns while enjoying the speed benefits of our TypeScript engine.
|
|
568
|
+
By maintaining Sqitch compatibility while supercharging performance, pgpm enables you to keep your existing migration patterns while enjoying the speed benefits of our TypeScript engine.
|
|
580
569
|
|
|
581
570
|
## `getConnections` Options
|
|
582
571
|
|
|
@@ -689,18 +678,18 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
|
|
|
689
678
|
|
|
690
679
|
### 🔁 Streaming & Uploads
|
|
691
680
|
|
|
681
|
+
* [etag-hash](https://github.com/constructive-io/constructive/tree/main/packages/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
|
|
682
|
+
* [etag-stream](https://github.com/constructive-io/constructive/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
|
|
683
|
+
* [uuid-hash](https://github.com/constructive-io/constructive/tree/main/packages/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
|
|
684
|
+
* [uuid-stream](https://github.com/constructive-io/constructive/tree/main/packages/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
|
|
692
685
|
* [launchql/s3-streamer](https://github.com/constructive-io/constructive/tree/main/packages/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
|
|
693
|
-
* [launchql/etag-hash](https://github.com/constructive-io/constructive/tree/main/packages/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
|
|
694
|
-
* [launchql/etag-stream](https://github.com/constructive-io/constructive/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
|
|
695
|
-
* [launchql/uuid-hash](https://github.com/constructive-io/constructive/tree/main/packages/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
|
|
696
|
-
* [launchql/uuid-stream](https://github.com/constructive-io/constructive/tree/main/packages/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
|
|
697
686
|
* [launchql/upload-names](https://github.com/constructive-io/constructive/tree/main/packages/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
|
|
698
687
|
|
|
699
688
|
### 🧰 CLI & Codegen
|
|
700
689
|
|
|
701
690
|
* [pgpm](https://github.com/constructive-io/constructive/tree/main/packages/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
|
|
702
691
|
* [@launchql/cli](https://github.com/constructive-io/constructive/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing LaunchQL projects—supports database scaffolding, migrations, seeding, code generation, and automation.
|
|
703
|
-
* [
|
|
692
|
+
* [launchql-gen](https://github.com/constructive-io/constructive/tree/main/packages/launchql-gen): **✨ Auto-generated GraphQL** mutations and queries dynamically built from introspected schema data.
|
|
704
693
|
* [@launchql/query-builder](https://github.com/constructive-io/constructive/tree/main/packages/query-builder): **🏗️ SQL constructor** providing a robust TypeScript-based query builder for dynamic generation of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and stored procedure calls—supports advanced SQL features like `JOIN`, `GROUP BY`, and schema-qualified queries.
|
|
705
694
|
* [@launchql/query](https://github.com/constructive-io/constructive/tree/main/packages/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
|
|
706
695
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supabase-test",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"author": "Interweb <developers@interweb.io>",
|
|
5
5
|
"description": "supabase-test offers isolated, role-aware, and rollback-friendly PostgreSQL environments for integration tests with Supabase defaults baked in",
|
|
6
6
|
"main": "index.js",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"test:watch": "jest --watch"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@pgpmjs/types": "^2.12.
|
|
55
|
+
"@pgpmjs/types": "^2.12.1",
|
|
56
56
|
"pg-env": "^1.2.1",
|
|
57
|
-
"pgsql-test": "^2.16.
|
|
57
|
+
"pgsql-test": "^2.16.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"makage": "^0.1.8"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "52828c38b144fdc02b6a9a0c8b0ff795d1752d53"
|
|
63
63
|
}
|