playwright
playwright copied to clipboard
[Feature] Ability to attach screenshots / videos / traces captured in globalSetup / teardown to html report
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.
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 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)
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
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.
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!
Closing per above.