Skip to content

Commit

Permalink
update reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
rlingineni committed Feb 15, 2024
1 parent 2b9c539 commit 2b85ee5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions playwright/reporters/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,58 @@ const FailedRuns = {};
let startTime = 0;
class MyReporter {
onBegin(config, suite) {
console.log(`This is an automated test report`);
console.log(`Running ${suite.allTests().length} tests`);
startTime = new Date().getTime();
}

onTestBegin() {}

onTestEnd(test, result) {
if (result.status === 'failed' && test.retry > 1) {
if (result.status === 'failed') {
// get the first word of the test title
const title = test.title.split(' ')[0];
FailedRuns[title] = test;
}
}

onEnd(result) {
onEnd() {
// duration
const endTime = new Date().getTime();
const duration = endTime - startTime;
// get duration in minutes and seconds
const minutes = Math.floor(duration / 60000);
const seconds = ((duration % 60000) / 1000).toFixed(0);

console.log(`This is an automated visual test report.`);

if (result.status === 'failed') {
if (Object.keys(FailedRuns).length > 0) {
console.log(`### Failed Visual Snapshots ❌`);
console.log('-----------------------------------');
console.log(
'These test failures may or may not be related to your changes. These are not blocking.',
'Note: These test failures may or may not be related to your changes. They are not blocking.',
);

console.log('');
console.log(Object.keys(FailedRuns).length, ' failed visual tests:');

Object.keys(FailedRuns).forEach((title) => {
console.log(`- ${title}`);
});

console.log(`To see the failed tests, run the following command:`);
console.log(`yarn run playwright:visual-test test --ui"`);
console.log(`To see the failed tests, run the following command locally:`);
console.log(`\`yarn run playwright:visual-test test --ui\``);

console.log('');
console.log('');

console.log(`To update failed tests, run`);
console.log(`yarn run playwright:visual-test --update-snapshots"`);
console.log(`\`yarn run playwright:visual-test --update-snapshots\``);

console.log('');

console.log(`Total Test Run Time: ${minutes}:${seconds}`);
console.log(`Total Test Run Time: ${minutes}m ${seconds}s`);
} else {
console.log(`All visual tests passed ✅`);
console.log(`Total Test Run Time: ${minutes}:${seconds}`);
console.log(`Total Test Run Time: ${minutes}m ${seconds}s`);
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b85ee5

Please sign in to comment.