refacto config test
This commit is contained in:
@@ -14,4 +14,11 @@ module.exports = {
|
||||
'^@app/(.*)$': '<rootDir>/src/app/$1',
|
||||
'^@env/(.*)$': '<rootDir>/src/environments/$1',
|
||||
},
|
||||
// Ajouter cette section pour gérer les warnings Node.js
|
||||
testEnvironmentOptions: {
|
||||
customExportConditions: ['node', 'node-addons'],
|
||||
},
|
||||
|
||||
// Supprimer les warnings de dépréciation
|
||||
setupFiles: ['<rootDir>/suppress-deprecation-warnings.js'],
|
||||
};
|
||||
|
||||
@@ -32,23 +32,47 @@ global.fetch = jest.fn(() =>
|
||||
})
|
||||
) as jest.Mock;
|
||||
|
||||
// 🟡 Ignore le warning pdfjs-dist
|
||||
// 🟡 Ignore les warnings pdfjs-dist
|
||||
const originalWarn = console.warn;
|
||||
console.warn = (...args) => {
|
||||
if (
|
||||
typeof args[0] === 'string' &&
|
||||
args[0].includes('ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG')
|
||||
) {
|
||||
const message = typeof args[0] === 'string' ? args[0] : '';
|
||||
|
||||
// Liste des warnings à ignorer
|
||||
const ignoredWarnings = [
|
||||
'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG',
|
||||
'loadPackages',
|
||||
'pdfjs-dist',
|
||||
];
|
||||
|
||||
if (ignoredWarnings.some((warning) => message.includes(warning))) {
|
||||
return;
|
||||
}
|
||||
|
||||
originalWarn(...args);
|
||||
};
|
||||
|
||||
// 🔴 Ignore le log angularx-qrcode après les tests
|
||||
const originalError = console.error;
|
||||
console.error = (...args) => {
|
||||
if (typeof args[0] === 'string' && args[0].includes('[angularx-qrcode]')) {
|
||||
// 🟡 Ignore les logs angularx-qrcode
|
||||
const originalLog = console.log;
|
||||
console.log = (...args) => {
|
||||
const message = typeof args[0] === 'string' ? args[0] : '';
|
||||
|
||||
const ignoredLogs = ['Warning: loadPackages', 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG'];
|
||||
|
||||
if (ignoredLogs.some((log) => message.includes(log))) {
|
||||
return;
|
||||
}
|
||||
|
||||
originalLog(...args);
|
||||
};
|
||||
|
||||
// 🔴 Ignore les errors angularx-qrcode
|
||||
const originalError = console.error;
|
||||
console.error = (...args) => {
|
||||
const message = typeof args[0] === 'string' ? args[0] : '';
|
||||
|
||||
if (message.includes('[angularx-qrcode]')) {
|
||||
return;
|
||||
}
|
||||
|
||||
originalError(...args);
|
||||
};
|
||||
|
||||
9
suppress-deprecation-warnings.js
Normal file
9
suppress-deprecation-warnings.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// suppress-deprecation-warnings.js
|
||||
const originalEmitWarning = process.emitWarning;
|
||||
|
||||
process.emitWarning = (warning, type, code, ...args) => {
|
||||
if (code === 'DEP0040') {
|
||||
return;
|
||||
}
|
||||
return originalEmitWarning.call(process, warning, type, code, ...args);
|
||||
};
|
||||
Reference in New Issue
Block a user