Modify error output to include test name, test path, current URL

33 views Asked by At

I would like to add the test name, test path and current URL to my error messages, so that they would show with the Browser: and Screenshots: info. Is this possible, and how?

Example of what I would like to have:

- Error message -
AssertionError: expected false to be truthy

Test name: This is my test name
Test path: C:\e2e-testing\tests\test.js
Test URL: <current_test_URL> 

Browser: Chrome 112.0.0.0 / Windows 11
Screenshot: C:\e2e-testing\screenshots\2023-04-20_10-48-53\test-1\Chrome_112.0.0.0_Windows_11\errors\1.png

37 | stacktrace here

Could I do it with a custom reporter or with hooks?

1

There are 1 answers

0
Pavel Morozov On

You can use the onBeforeWrite hook to modify the reporter output. The default spec reporter does not offer information about the specific page where an error occurred. However, you can explore community reports that offer such information and also use a hook to customize their output.

See the help topic describing Modify Reporter Output.