Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

insforge-test

Latest version: v1.19.16

Overview

Last scanned
23 Nov 2026
Published
23 Nov 2026
npm package Publisher: pyramation
60 Stars
7 Forks
43 Versions
6.4K Downloads
TypeScript Repo language

Scan summary

insforge-test was last scanned on 23 Nov 2026 at version 1.19.16. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 43 versions; the latest 5 were published within 5 days (19–23 Nov 2026).
  • Findings: No rules fired in version 1.19.16.
  • Downloads: 6,367 downloads.

Versions

43 versions published
Versions and the rules that fired in each
VersionPublishedStatus
1.19.16 LATEST 23 Nov 2026 No rules fired
1.19.15 23 Nov 2026 No rules fired
1.19.14 23 Nov 2026 No rules fired
1.19.12 21 Nov 2026 Not shown
1.19.11 19 Nov 2026 Not shown

No rules fired in 1.19.16

Findings

Findings for v1.19.16. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 1.19.16; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

insforge-test

insforge-test is an InsForge-optimized version of pgsql-test with InsForge defaults baked in. It provides instant, isolated PostgreSQL databases for testing with automatic transaction rollbacks, context switching, and clean seeding — configured for InsForge's local development environment. It's also great for GitHub Actions and CI/CD testing.

Install

npm install insforge-test

Features

  • Instant test DBs — each one seeded, isolated, and UUID-named
  • Per-test rollback — every test runs in its own transaction or savepoint
  • RLS-friendly — test with role-based auth via .setContext()
  • Flexible seeding — run .sql files, programmatic seeds, or even load fixtures
  • Compatible with any async runner — works with Jest, Mocha, etc.
  • Auto teardown — no residue, no reboots, just clean exits

Quick Start

import { getConnections } from 'insforge-test';

let db, teardown;

beforeAll(async () => {
  ({ db, teardown } = await getConnections());
  await db.query(`SELECT 1`); // Ready to run queries
});

afterAll(() => teardown());

getConnections() Overview

import { getConnections } from 'insforge-test';

// Complete object destructuring
const { pg, db, admin, teardown, manager } = await getConnections();

// Most common pattern
const { db, teardown } = await getConnections();

The getConnections() helper sets up a fresh PostgreSQL test database and returns a structured object with:

  • pg: a PgTestClient connected as the root or superuser — useful for administrative setup or introspection
  • db: a PgTestClient connected as the app-level user — used for running tests with RLS and granted permissions
  • admin: a DbAdmin utility for managing database state, extensions, roles, and templates
  • teardown(): a function that shuts down the test environment and database pool
  • manager: a shared connection pool manager (PgTestConnector) behind both clients

Together, these allow fast, isolated, role-aware test environments with per-test rollback and full control over setup and teardown.

The PgTestClient returned by getConnections() is a fully-featured wrapper around pg.Pool. It provides:

  • Automatic transaction and savepoint management for test isolation
  • Easy switching of role-based contexts for RLS testing
  • A clean, high-level API for integration testing PostgreSQL systems

PgTestClient API Overview

let pg: PgTestClient;
let teardown: () => Promise<void>;

beforeAll(async () => {
  ({ pg, teardown } = await getConnections());
});

beforeEach(() => pg.beforeEach());
afterEach(() => pg.afterEach());
afterAll(() => teardown());

The PgTestClient returned by getConnections() wraps a pg.Client and provides convenient helpers for query execution, test isolation, and context switching.

Common Methods
  • query(sql, values?) – Run a raw SQL query and get the QueryResult
  • beforeEach() – Begins a transaction and sets a savepoint (called at the start of each test)
  • afterEach() – Rolls back to the savepoint and commits the outer transaction (cleans up test state)
  • setContext({ key: value }) – Sets PostgreSQL config variables (like role) to simulate RLS contexts
  • any, one, oneOrNone, many, manyOrNone, none, result – Typed query helpers for specific result expectations

These methods make it easier to build expressive and isolated integration tests with strong typing and error handling.

The PgTestClient returned by getConnections() is a fully-featured wrapper around pg.Pool. It provides:

  • Automatic transaction and savepoint management for test isolation
  • Easy switching of role-based contexts for RLS testing
  • A clean, high-level API for integration testing PostgreSQL systems

Usage Examples

Basic Setup
import { getConnections } from 'insforge-test';

let db; // A fully wrapped PgTestClient using pg.Pool with savepoint-based rollback per test
let teardown;

beforeAll(async () => {
  ({ db, teardown } = await getConnections());

  await db.query(`
    CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);
    CREATE TABLE posts (id SERIAL PRIMARY KEY, user_id INT REFERENCES users(id), content TEXT);

    INSERT INTO users (name) VALUES ('Alice'), ('Bob');
    INSERT INTO posts (user_id, content) VALUES (1, 'Hello world!'), (2, 'Testing InsForge!');
  `);
});

afterAll(() => teardown());

beforeEach(() => db.beforeEach());
afterEach(() => db.afterEach());

test('user count starts at 2', async () => {
  const res = await db.query('SELECT COUNT(*) FROM users');
  expect(res.rows[0].count).toBe('2');
});
Role-Based Context

The insforge-test framework provides powerful tools to simulate authentication contexts during tests, which is particularly useful when testing Row-Level Security (RLS) policies.

Setting Test Context

Use setContext() to simulate different user roles and JWT claims:

db.setContext({
  role: 'authenticated',
  'request.jwt.claim.sub': '550e8400-e29b-41d4-a716-446655440001'
});

This applies the settings using SET LOCAL statements, ensuring they persist only for the current transaction and maintain proper isolation between tests.

InsForge Roles

InsForge uses three built-in PostgreSQL roles:

Role Description Use Case
anon Unauthenticated users Public read access
authenticated Logged-in users Standard user operations
project_admin System administrators Full access to all resources
Testing Role-Based Access
describe('authenticated role', () => {
  beforeEach(async () => {
    db.setContext({ role: 'authenticated' });
    await db.beforeEach();
  });

  afterEach(() => db.afterEach());

  it('runs as authenticated', async () => {
    const res = await db.query(`SELECT current_setting('role', true) AS role`);
    expect(res.rows[0].role).toBe('authenticated');
  });
});
Creating Test Users

Use insertUser() to create users in auth.users:

import { getConnections, PgTestClient, insertUser } from 'insforge-test';

let pg: PgTestClient;
let db: PgTestClient;
let teardown: () => Promise<void>;

let alice: any;
let bob: any;

beforeAll(async () => {
  ({ pg, db, teardown } = await getConnections());

  // Create users in auth.users (requires superuser)
  alice = await insertUser(pg, 'alice@example.com', '550e8400-e29b-41d4-a716-446655440001');
  bob = await insertUser(pg, 'bob@example.com', '550e8400-e29b-41d4-a716-446655440002');
});

Parameters:

  • pg - Superuser client (required for auth.users)
  • email - User's email
  • id - Optional UUID (auto-generated if omitted)
Testing RLS Policies
User Can Access Own Data
it('user can insert own record', async () => {
  db.setContext({
    role: 'authenticated',
    'request.jwt.claim.sub': alice.id
  });

  const result = await db.one(`
    INSERT INTO public.posts (title, owner_id)
    VALUES ($1, $2)
    RETURNING id, title, owner_id
  `, ['My Post', alice.id]);

  expect(result.title).toBe('My Post');
  expect(result.owner_id).toBe(alice.id);
});
User Cannot Access Others' Data
it('user cannot see other users data', async () => {
  // Bob creates a post
  db.setContext({
    role: 'authenticated',
    'request.jwt.claim.sub': bob.id
  });

  await db.one(`
    INSERT INTO public.posts (title, owner_id)
    VALUES ($1, $2)
    RETURNING id
  `, ['Bob Post', bob.id]);

  // Alice queries - should not see Bob's post
  db.setContext({
    role: 'authenticated',
    'request.jwt.claim.sub': alice.id
  });

  const result = await db.query('SELECT * FROM public.posts');
  expect(result.rows).toHaveLength(0);
});
Testing Permission Denied

Use savepoint pattern for expected failures:

it('anonymous cannot insert', async () => {
  db.setContext({ role: 'anon' });

  const point = 'anon_insert';
  await db.savepoint(point);

  await expect(
    db.query(`INSERT INTO public.posts (title) VALUES ('Hacked')`)
  ).rejects.toThrow(/permission denied/);

  await db.rollback(point);
});
Seeding System

The second argument to getConnections() is an optional array of SeedAdapter objects:

const { db, teardown } = await getConnections(getConnectionOptions, seedAdapters);

This array lets you fully customize how your test database is seeded. You can compose multiple strategies:

  • seed.sqlfile() – Execute raw .sql files from disk
  • seed.fn() – Run JavaScript/TypeScript logic to programmatically insert data
  • seed.csv() – Load tabular data from CSV files
  • seed.json() – Use in-memory objects as seed data
  • seed.pgpm() – Apply a PGPM project or set of packages (compatible with sqitch)

Default Behavior: If no SeedAdapter[] is passed, pgpm seeding is assumed. This makes insforge-test zero-config for pgpm-based projects.

SQL File Seeding
const { db, teardown } = await getConnections({}, [
  seed.sqlfile(['schema.sql', 'fixtures.sql'])
]);
Programmatic Seeding
const { db, teardown } = await getConnections({}, [
  seed.fn(async ({ pg }) => {
    await pg.query(`INSERT INTO users (name) VALUES ('Seeded User')`);
  })
]);
JSON Seeding
const { db, teardown } = await getConnections({}, [
  seed.json({
    'public.users': [
      { id: 1, name: 'Alice' },
      { id: 2, name: 'Bob' }
    ]
  })
]);
pgpm Seeding
// pgpm migrate is used automatically
const { db, teardown } = await getConnections();

getConnections Options

db Options (PgTestConnectionOptions)
Option Type Default Description
db.extensions string[] [] Array of PostgreSQL extensions to include in the test database
db.cwd string process.cwd() Working directory used for PGPM or Sqitch projects
db.connection.user string 'postgres' User for simulating RLS via setContext()
db.connection.password string 'postgres' Password for RLS test user
db.connection.role string 'anon' Default role used during setContext()
db.template string undefined Template database used for faster test DB creation
db.rootDb string 'postgres' Root database used for administrative operations (e.g., creating databases)
db.prefix string 'db-' Prefix used when generating test database names
pg Options (PgConfig)

Environment variables will override these options when available:

  • PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE
Option Type Default Description
pg.user string 'postgres' Superuser for PostgreSQL
pg.password string 'postgres' Password for the PostgreSQL superuser
pg.host string 'localhost' Hostname for PostgreSQL
pg.port number 5432 Port for PostgreSQL
pg.database string 'postgres' Default database used when connecting initially
Usage
const { conn, db, teardown } = await getConnections({
  pg: { user: 'postgres', password: 'secret' },
  db: {
    extensions: ['uuid-ossp'],
    cwd: '/path/to/project',
    connection: { user: 'test_user', password: 'secret', role: 'authenticated' },
    template: 'test_template',
    prefix: 'test_',
    rootDb: 'postgres'
  }
});

InsForge vs Supabase Defaults

If you're coming from supabase-test, here are the key differences:

Setting supabase-test insforge-test
Admin role service_role project_admin
App user supabase_admin postgres
Default port 54322 5432
JWT claim key request.jwt.claim.sub request.jwt.claim.sub

The anonymous (anon) and authenticated (authenticated) roles are identical across both platforms.

Snapshot Utilities

The insforge-test/utils module provides utilities for sanitizing query results for snapshot testing. These helpers replace dynamic values (IDs, UUIDs, dates, hashes) with stable placeholders, making snapshots deterministic.

import { snapshot } from 'insforge-test/utils';

const result = await db.any('SELECT * FROM users');
expect(snapshot(result)).toMatchSnapshot();

See pgsql-test Snapshot Utilities for the full API reference.


Education and Tutorials

  1. 🚀 Quickstart: Getting Up and Running Get started with modular databases in minutes. Install prerequisites and deploy your first module.

  2. 📦 Modular PostgreSQL Development with Database Packages Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.

  3. ✏️ Authoring Database Changes Master the workflow for adding, organizing, and managing database changes with pgpm.

  4. 🧪 End-to-End PostgreSQL Testing with TypeScript Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.

  5. ⚡ Supabase Testing Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.

  6. 💧 Drizzle ORM Testing Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.

  7. 🔧 Troubleshooting Common issues and solutions for pgpm, PostgreSQL, and testing.

Related Constructive Tooling

📦 Package Management
  • pgpm: 🖥️ PostgreSQL Package Manager for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
🧪 Testing

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm insforge-test

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Critical Apache HTTP Server Flaw Exposes Web Servers to RCE (1)
CVE

CVE-2026-119618: Critical Apache HTTP Server Flaw Exposes Web Servers to Remote Code Execution

Ethersphere Hijacked With Crypto Stealing Malware (1)
npm

Ethersphere Hijacked With Crypto Stealing Malware Via Github & npm

Vulnerability Insights

Compromised Claude Code extensions (versions 2.1.312 & 2.1.313) in Cursor try to install a backdoor

Frame 2085668439 (1)
Group 1261154229