-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.global-setup.js
More file actions
35 lines (33 loc) · 1.22 KB
/
jest.global-setup.js
File metadata and controls
35 lines (33 loc) · 1.22 KB
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
27
28
29
30
31
32
33
34
35
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
module.exports = async () => {
try {
// Check for local Prisma query engine binary
const engineDir = path.join(__dirname, '../prisma-engines');
let engineBinaryPath = '';
if (fs.existsSync(engineDir)) {
const engineBinary = fs.readdirSync(engineDir).find(file =>
file.startsWith('query-engine') && file.endsWith('.node')
);
if (engineBinary) {
engineBinaryPath = path.join(engineDir, engineBinary);
process.env.PRISMA_QUERY_ENGINE_BINARY = engineBinaryPath;
console.log(`Using bundled Prisma engine binary: ${engineBinaryPath}`);
}
}
console.log('Running prisma generate...');
execSync('npx prisma generate', { stdio: 'inherit' });
console.log('Running prisma migrate deploy...');
execSync('npx prisma migrate deploy', { stdio: 'inherit' });
try {
console.log('Running prisma db seed...');
execSync('npx prisma db seed', { stdio: 'inherit' });
} catch (err) {
console.log('Seed script not found or failed, proceeding...');
}
} catch (err) {
console.error('Error during global setup:', err);
throw err;
}
};