Database Test
Query and validate database stateEdit
Run SQL queries and validate database state directly. Database tests connect to your databases securely and execute queries with result validation.
Create Test
- Go to Create → Database Test
- Select database connection
- Write SQL query
- Add assertions
- Run and save
Example
/**
* PostgreSQL read health check.
*
* Purpose:
* - Verify database connectivity
* - Check that a specific table exists and has expected columns
* - Ensure read operations are functioning
*
* Configuration:
* - Requires 'pg' library (included in Supercheck runtime)
* - Connection string must be configured via project variables
*
* @requires pg - PostgreSQL client for Node.js
*/
import { expect, test } from '@playwright/test';
import { Pool } from 'pg';
const pool = new Pool({
host: getVariable('DB_HOST'),
port: parseInt(getVariable('DB_PORT') || '5432'),
database: getVariable('DB_NAME'),
user: getVariable('DB_USER'),
password: getSecret('DB_PASSWORD'),
});
test.afterAll(async () => {
await pool.end();
});
test.describe('database read health check', () => {
test('users table returns expected columns', async () => {
// Execute a simple SELECT query
const result = await pool.query('SELECT id, email FROM users LIMIT 1');
// Verify we got results and the schema matches expectations
expect(result.rowCount).toBeGreaterThan(0);
expect(result.rows[0]).toHaveProperty('email');
});
});Supported Databases
| Type | Databases |
|---|---|
| Relational | PostgreSQL, MySQL, SQL Server, MariaDB |
| Cloud | Amazon RDS, Azure SQL, Google Cloud SQL |
Connection Methods
- Direct — Public database with credentials
- SSH Tunnel — Private network via bastion host
- Secrets — Store credentials securely with
getSecret()
Common Assertions
| Assertion | Example |
|---|---|
| Row count | COUNT(*) > 0 |
| Value check | status = 'active' |
| Not null | email IS NOT NULL |