forked from ricsf2000/VolunteerEngine
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjest.globalSetup.js
More file actions
26 lines (20 loc) · 788 Bytes
/
Copy pathjest.globalSetup.js
File metadata and controls
26 lines (20 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const { execSync } = require('child_process');
module.exports = async () => {
console.log('Starting test database...');
try {
// Start Docker container
execSync('npm run db:up', { stdio: 'inherit' });
// Wait a bit for PostgreSQL to be ready
console.log('Waiting for database to be ready...');
await new Promise(resolve => setTimeout(resolve, 5000));
// Push schema and seed data
console.log('Setting up database schema...');
execSync('npm run db:push', { stdio: 'inherit' });
console.log('Seeding test data...');
execSync('npm run db:seed', { stdio: 'inherit' });
console.log('Test database ready');
} catch (error) {
console.error('Failed to setup test database:', error.message);
process.exit(1);
}
};