Kyuri Docs

Database Test

Query and validate database state

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

Write SQL query

Add assertions

Run and save

Database connections are defined inline in your script. Use getVariable() for connection details such as host, port, database, and user, and getSecret() for the password (see the example below). There is no separate connection picker in the UI.

Example

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');
  });
});

On this page