({ provide })
| 1 | import { testDbManager } from "./helpers/testDbManager.js"; |
| 2 | |
| 3 | export default async function globalSetup({ provide }) { |
| 4 | console.log("🚀 Starting global test setup..."); |
| 5 | |
| 6 | // Set test environment variables |
| 7 | process.env.NODE_ENV = "test"; |
| 8 | process.env.CB_SECRET = "test-secret-key-for-testing-only"; |
| 9 | process.env.CB_ENCRYPTION_KEY = "0123456789abcdef0123456789abcdef"; // 32-char hex for testing |
| 10 | process.env.CB_API_HOST = "127.0.0.1"; |
| 11 | process.env.CB_API_PORT = "0"; // Let the system assign a random port |
| 12 | |
| 13 | // Use containerized MySQL by default for testing. |
| 14 | process.env.CB_DB_DIALECT_DEV = process.env.CB_DB_DIALECT_DEV || "mysql"; |
| 15 | |
| 16 | // The global setup owns the container; test workers reuse it via provided |
| 17 | // connection details instead of starting their own containers. |
| 18 | delete process.env.CB_TEST_DB_REUSE; |
| 19 | |
| 20 | // Start test database container (will be shared across all tests) |
| 21 | await testDbManager.start(); |
| 22 | |
| 23 | provide("testDbConnection", testDbManager.getConnectionDetails()); |
| 24 | |
| 25 | console.log("✅ Global test setup completed"); |
| 26 | |
| 27 | return async () => { |
| 28 | console.log("🧹 Starting global test teardown..."); |
| 29 | await testDbManager.stop(); |
| 30 | console.log("✅ Global test teardown completed"); |
| 31 | }; |
| 32 | } |
nothing calls this directly
no test coverage detected