Open pgarbocz opened 3 months ago
Maybe you could use a fixture:
import { test as base } from '@playwright/test';
export const test = base.extend<{ testHook: void }>({
testHook: [
async ({ }, use): Promise<void> => {
// Any code here will be run as a before each hook
// See more: https://playwright.dev/docs/test-fixtures#execution-order
console.log(`Playwright worker: ${test.info().workerIndex}\n`);
console.log(`Test started at ${new Date().toString()}\n`);
await use();
// Any code here will be run as a after each hook
console.log(`Test finished at ${new Date().toString()}\n`);
},
// Automatic fixtures are set up for each test/worker, even when the test does not list them directly
// See more: https://playwright.dev/docs/test-fixtures#automatic-fixtures
{ auto: true },
],
});
@brunojbarros Yes, that's a workaround, but then the reporter spams these logs for each tests when run in command.
🚀 Feature Request
It would be nice to have timestamps of start and completion of a test inside the HTML report and also in the CI reporters, like list reporter, to know when the tested application failed and what time I should look at in the application logs.
For CI reporters maybe it makes more sense to print timestamps only in the details of the failed tests to not break the slim format.
Example
No response
Motivation
When we run the tests for the application on a test server, they generates a lot of logs of our application. When some test fail, we need to check the logs to see if there are any exceptions/errors. If we had the timestamps when it started and when it completed the test (either succeeded or failed), we could easily find the proper piece of logs.
From what I saw, in JUnit xml there is a timestamp and duration time, thanks to that Azure Devops can present Date started and Date completed for each test case.