refacto config test
This commit is contained in:
@@ -14,4 +14,11 @@ module.exports = {
|
|||||||
'^@app/(.*)$': '<rootDir>/src/app/$1',
|
'^@app/(.*)$': '<rootDir>/src/app/$1',
|
||||||
'^@env/(.*)$': '<rootDir>/src/environments/$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;
|
) as jest.Mock;
|
||||||
|
|
||||||
// 🟡 Ignore le warning pdfjs-dist
|
// 🟡 Ignore les warnings pdfjs-dist
|
||||||
const originalWarn = console.warn;
|
const originalWarn = console.warn;
|
||||||
console.warn = (...args) => {
|
console.warn = (...args) => {
|
||||||
if (
|
const message = typeof args[0] === 'string' ? args[0] : '';
|
||||||
typeof args[0] === 'string' &&
|
|
||||||
args[0].includes('ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG')
|
// Liste des warnings à ignorer
|
||||||
) {
|
const ignoredWarnings = [
|
||||||
|
'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG',
|
||||||
|
'loadPackages',
|
||||||
|
'pdfjs-dist',
|
||||||
|
];
|
||||||
|
|
||||||
|
if (ignoredWarnings.some((warning) => message.includes(warning))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
originalWarn(...args);
|
originalWarn(...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 🔴 Ignore le log angularx-qrcode après les tests
|
// 🟡 Ignore les logs angularx-qrcode
|
||||||
const originalError = console.error;
|
const originalLog = console.log;
|
||||||
console.error = (...args) => {
|
console.log = (...args) => {
|
||||||
if (typeof args[0] === 'string' && args[0].includes('[angularx-qrcode]')) {
|
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;
|
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);
|
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