Skip to content

Commit 2399757

Browse files
committed
Added Custom Loggers on TestCase/TestStep level
1 parent 994bb55 commit 2399757

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

CustomReporterConfig.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Reporter, TestCase, TestResult, TestStep } from "@playwright/test/reporter";
2+
3+
export default class CustomReporterConfig {
4+
5+
onTestBegin(test: TestCase): void {
6+
console.log(`Test Case Started : ${test.title}`);
7+
}
8+
9+
onTestEnd?(test: TestCase, result: TestResult): void {
10+
console.log(`Test Case Completed : ${test.title} Status : ${result.status}`);
11+
}
12+
13+
onStepBegin?(test: TestCase, result: TestResult, step: TestStep): void {
14+
if (step.category === `test.step`) {
15+
console.log(`Executing Step : ${step.title}`);
16+
}
17+
}
18+
19+
onError(error: TestError) {
20+
console.log(error.message);
21+
}
22+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ npm run test:report
158158
14. To change password, go to `lib/WebActions` in `decipherPassword()` uncomment `ENCRYPT` code block and replace `password` with your password, execute the test case, Encrypted password will be printed on your console . Copy Encrypted password in `testData.json` against `password` field. You can comment Encrypt bloack ater this.
159159
15. For executing Postgres DB test case, navigate to `testData.json` and provide values for `dbUsername, dbPassword, dbServerName, dbPort, dbName`. Refer to `tests/DB.test.ts` for connecting to DB and Firing a Query.
160160
16. For viewing trace files, go to folder where `trace.zip` is generated and execute :
161-
162161
```JS
163162
npx playwright show-trace trace.zip
164163
```
164+
17. You can change the Logging Message at Test Case/Test Step Level in CustomReporterConfig.ts file
165165

166166
## Reports
167167

playwright.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { devices } from 'playwright';
22

33
module.exports = {
44
//sets timeout for each test case
5-
timeout: 300000,
5+
timeout: 120000,
66

77
//number of retries if test case fails
88
retries: 0,
99

1010
//Reporters
11-
reporter: [[`list`], [`experimental-allure-playwright`]],
11+
reporter: [[`./CustomReporterConfig.ts`], [`experimental-allure-playwright`]],
1212

1313
projects: [
1414
{

0 commit comments

Comments
 (0)