Files
wmantly 12da7140c2 test: dockerized test suite (openldap + redis + test-runner)
docker-compose.test.yml spins up the all-in-one OpenLDAP image, a
standalone Redis, and a test-runner that seeds the test user and runs
jest against them. globalSetup honors REDIS_URL; tests/setup.js
initializes the ORM and flushes test Redis keys before the run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 02:20:59 -04:00

22 lines
681 B
JavaScript

'use strict';
// Flush all test-prefix Redis keys before each test run so state is always clean.
// Uses model-redis's own bundled redis client since redis is not a top-level dep.
const { createClient } = require('redis');
module.exports = async function() {
const redisUrl = process.env.REDIS_URL || undefined;
const client = createClient(redisUrl ? { url: redisUrl } : {});
await client.connect();
const keys = await client.keys('sso_manager_test_*');
if (keys.length) {
await client.del(keys);
console.log(`[globalSetup] Flushed ${keys.length} test Redis key(s).`);
} else {
console.log('[globalSetup] No test Redis keys to flush.');
}
await client.quit();
};