playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature] Ability to attach screenshots / videos / traces captured in globalSetup / teardown to html report

Open vijaydubber opened this issue 3 years ago • 4 comments

we have testInfo.attach(), but there won't be any tests when globalSetup is running. So won't be able to attach at that level.

This would be especially useful when running tests in CI, because the HTML will show all the tests as skipped, and won't have any information on why it was skipped.

vijaydubber avatar Jul 29 '22 07:07 vijaydubber

Hi @pavelfeldman , @rwoll I would also like to request the steps executed in the global setup /teardown be available in the html report (like how each steps in a regular test is reported with code line and time taken for execution).

Do I need to raise a new feature request for that. I understand the requirement may not fit nicely with the existing html reporting, but these features would be very helpful.

vijaydubber avatar Aug 02 '22 02:08 vijaydubber

@vijaydubber I think we'll end up covering that in https://github.com/microsoft/playwright/issues/14895 (which is a new idea as of this morning)

rwoll avatar Aug 02 '22 20:08 rwoll

For anyone who's looking for a workaround: Make your global scripts save videos or traces in results/global, then follow the below steps: circle:

      - run:
          name: Copy global trace if exist
          command: bash .circleci/scripts/copyGlobalTrace.sh
          when: always 

.circleci/scripts/copyGlobalTrace.sh

if [ -d "results/global" ]; then
    # This means global step has generated video or trace files.. we would copy it over to html-report directory..

    # Install tree and generate directory listing for global video or trace files
    apt install tree -y
    /usr/bin/tree results/global -H . -o results/global/index.html

    #copy them over to html-report and add a link in html-report/index.html
    cp -r results/global results/html-report/global
    echo "<a href='global/index.html'>global/index.html</a>" >> results/html-report/index.html
fi

vijaydubber avatar Aug 08 '22 01:08 vijaydubber

Likely solved by https://github.com/microsoft/playwright/issues/14895#issuecomment-1207665459 which would relocate this setup code to a regular test which can take attachments as of today.

rwoll avatar Aug 08 '22 06:08 rwoll

Starting with v1.31 you'll be able to shape your global setup as a Playwright project: https://playwright.dev/docs/next/api/class-testproject#test-project-dependencies. You can set up tracing for your setup project and see your global setup in the trace viewer!

pavelfeldman avatar Feb 02 '23 21:02 pavelfeldman

Closing per above.

dgozman avatar Feb 13 '23 18:02 dgozman