Rayrun
← Back to Discord Forum

testInfo.stdout / test.info().stdout question

keithspeersposted in #help-playwright
Open in Discord

From https://playwright.dev/docs/api/class-testinfo I would expect this dummy test to have testInfo.stdout.length to be 3 I've checked the config and am NOT running with quiet set. From the example below, I've tried with test.info() and with passing in testInfo What am I missing? Thanks

`const { expect, test } = require('@playwright/test');

test('test stdout', async ({ page }, testInfo) => { const logs = [] const doLog = text => { console.log(text) logs.push(text) }

doLog('hello') console.log('in line') doLog('world')

await page.goto('https://playwright.dev/'); const name = await page.innerText('.navbar__title'); expect(name).toBe('Playwright');

expect(logs.length).toBeGreaterThan(0); expect(testInfo.stdout.length).toBeGreaterThan(0);

const testInfo2 = test.info() expect(testInfo2.stdout.length).toBeGreaterThan(0); })`

This thread is trying to answer question "Why doesn't testInfo.stdout capture logs during the test execution?"

3 replies

In my real life scenario, we are launching a webserver application via the test setup and it also logs to stdout. For the process that is launched we are tracking process.stdout and re-logging it to the test stdout using console.log. I was hoping that test.stdout would capture both the simple standalone example above and possibly also stdout from the server launched by the test, but for now, I'd be happy with just the test stdout

For anyone else looking at this, it seems that testInfo.stdout is updated, but not updated during the test

I've added a feature request to the Playwright repo (https://github.com/microsoft/playwright/issues/29062) asking for stdout to be updated during the test so that tests can include checks on stdout messages

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.