- Added Vitest as a dependency for improved testing capabilities. - Updated package.json with new test scripts for running tests, watching, and coverage reporting. - Configured ESLint to recognize test runner scripts and included them in the linting process. - Modified tsconfig.json to include Vitest types for better TypeScript support in tests.
63 lines
1.6 KiB
JavaScript
Executable File
63 lines
1.6 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
/**
|
|
* Script pour gérer PostCSS pendant les tests
|
|
* Renomme temporairement postcss.config.mjs pour éviter les erreurs Vitest
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { spawn } = require('child_process');
|
|
|
|
const postcssConfigPath = path.join(process.cwd(), 'postcss.config.mjs');
|
|
const postcssConfigBackupPath = path.join(
|
|
process.cwd(),
|
|
'postcss.config.mjs.testbak'
|
|
);
|
|
|
|
// Fonction pour restaurer le fichier
|
|
function restorePostCSS() {
|
|
if (fs.existsSync(postcssConfigBackupPath)) {
|
|
fs.renameSync(postcssConfigBackupPath, postcssConfigPath);
|
|
console.log('✓ PostCSS config restauré');
|
|
}
|
|
}
|
|
|
|
// Renommer le fichier PostCSS avant les tests
|
|
if (fs.existsSync(postcssConfigPath)) {
|
|
fs.renameSync(postcssConfigPath, postcssConfigBackupPath);
|
|
console.log('✓ PostCSS config temporairement désactivé pour les tests');
|
|
|
|
// Lancer Vitest avec reporter verbose pour plus de détails
|
|
const vitest = spawn('pnpm', ['vitest', '--run', '--reporter=verbose'], {
|
|
stdio: 'inherit',
|
|
});
|
|
|
|
// Restaurer le fichier après que Vitest ait terminé
|
|
vitest.on('close', (code) => {
|
|
restorePostCSS();
|
|
process.exit(code || 0);
|
|
});
|
|
|
|
// Gérer les signaux d'interruption
|
|
process.on('SIGINT', () => {
|
|
vitest.kill('SIGINT');
|
|
restorePostCSS();
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on('SIGTERM', () => {
|
|
vitest.kill('SIGTERM');
|
|
restorePostCSS();
|
|
process.exit(0);
|
|
});
|
|
} else {
|
|
// Si le fichier n'existe pas, lancer Vitest directement
|
|
const vitest = spawn('pnpm', ['vitest', '--run'], {
|
|
stdio: 'inherit',
|
|
});
|
|
|
|
vitest.on('close', (code) => {
|
|
process.exit(code || 0);
|
|
});
|
|
}
|