Skip to content

Commit cd7183a

Browse files
committed
up
1 parent 46b1126 commit cd7183a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

vitest.browser.config.mts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function buildBrowserStackCapabilities(config: typeof browserConfig) {
223223
local: process.env.BROWSERSTACK_LOCAL === 'true' ? true : false,
224224
// debug: true,
225225
networkLogs: false,
226-
consoleLogs: 'verbose' as const,
226+
// consoleLogs: 'verbose' as const,
227227
seleniumLogs: true,
228228
idleTimeout: 1800, // 30 minutes idle timeout,
229229
},
@@ -307,7 +307,19 @@ export default defineConfig({
307307
});
308308

309309
// Add middleware to inject console-capture script into HTML responses
310-
server.middlewares.use((_req, res, next) => {
310+
let requestCounter = 0;
311+
server.middlewares.use((req, res, next) => {
312+
const url = req.url || '';
313+
const method = req.method || '';
314+
const requestTime = new Date().toISOString();
315+
const requestId = ++requestCounter;
316+
317+
// Log incoming request
318+
console.log('→'.repeat(40));
319+
console.log(`[INCOMING REQUEST #${requestId}] ${method} ${url}`);
320+
console.log(`Time: ${requestTime}`);
321+
console.log('→'.repeat(40));
322+
311323
const originalWrite = res.write;
312324
const originalEnd = res.end;
313325
const chunks: any[] = [];
@@ -336,6 +348,20 @@ export default defineConfig({
336348
}
337349
}
338350

351+
// Log outgoing response
352+
const contentType = res.getHeader('content-type')?.toString() || 'unknown';
353+
const statusCode = res.statusCode;
354+
const contentLength = res.getHeader('content-length') || buffer.length;
355+
const responseTime = new Date().toISOString();
356+
357+
console.log('←'.repeat(40));
358+
console.log(`[OUTGOING RESPONSE #${requestId}] ${method} ${url}`);
359+
console.log(`Status: ${statusCode}`);
360+
console.log(`Content-Type: ${contentType}`);
361+
console.log(`Content-Length: ${contentLength}`);
362+
console.log(`Time: ${responseTime}`);
363+
console.log('←'.repeat(40));
364+
339365
// Restore original methods and send response
340366
res.write = originalWrite;
341367
res.end = originalEnd;

0 commit comments

Comments
 (0)