Skip to content

Commit ac77769

Browse files
committed
chore(rsc-mf): log failing host action responses in tests
1 parent c7b6278 commit ac77769

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

tests/integration/rsc-mf/tests/index.test.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,36 @@ function runTests({ mode }: TestConfig) {
219219
browser = await puppeteer.launch(launchOptions as any);
220220
page = await browser.newPage();
221221

222-
if (mode === 'build') {
223-
page.on('pageerror', error => {
224-
runtimeErrors.push((error as Error).message);
225-
});
226-
}
222+
page.on('pageerror', error => {
223+
const err = error as Error;
224+
const message = err.message;
225+
runtimeErrors.push(message);
226+
// Debugging aid for flaky integration failures.
227+
console.log(`[pageerror:${mode}] ${message}`);
228+
if (err.stack) {
229+
console.log(`[pageerror:${mode}:stack] ${err.stack}`);
230+
}
231+
});
232+
page.on('console', msg => {
233+
if (msg.type() === 'error') {
234+
const location = msg.location();
235+
const suffix = location?.url
236+
? ` @ ${location.url}:${location.lineNumber}:${location.columnNumber}`
237+
: '';
238+
console.log(`[browser:${mode}] ${msg.text()}${suffix}`);
239+
}
240+
});
241+
page.on('response', async response => {
242+
if (response.status() >= 400 && response.url().includes(HOST_RSC_URL)) {
243+
console.log(
244+
`[response:${mode}] ${response.status()} ${response.url()}`,
245+
);
246+
const body = await response.text().catch(() => '');
247+
if (body) {
248+
console.log(`[response:${mode}:body] ${body}`);
249+
}
250+
}
251+
});
227252
});
228253

229254
afterAll(async () => {

0 commit comments

Comments
 (0)