mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
ci: Test container enhancements (#17008)
This commit is contained in:
26
packages/testing/containers/n8n-test-container-utils.ts
Normal file
26
packages/testing/containers/n8n-test-container-utils.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { Readable } from 'stream';
|
||||
|
||||
/**
|
||||
* Create a log consumer that does not log to the console
|
||||
* @returns A tuple containing the log consumer and a function to throw an error with logs
|
||||
*/
|
||||
export function createSilentLogConsumer() {
|
||||
const logs: string[] = [];
|
||||
|
||||
const consumer = (stream: Readable) => {
|
||||
stream.on('data', (chunk: Buffer | string) => {
|
||||
logs.push(chunk.toString().trim());
|
||||
});
|
||||
};
|
||||
|
||||
const throwWithLogs = (error: unknown): never => {
|
||||
if (logs.length > 0) {
|
||||
console.error('\n--- Container Logs ---');
|
||||
console.error(logs.join('\n'));
|
||||
console.error('---------------------\n');
|
||||
}
|
||||
throw error;
|
||||
};
|
||||
|
||||
return { consumer, throwWithLogs };
|
||||
}
|
||||
Reference in New Issue
Block a user