simonw / shot-scraper

A command-line utility for taking automated screenshots of websites
https://shot-scraper.datasette.io
Apache License 2.0
1.67k stars 73 forks source link

Mention playwright install requirement for tests in contributing.md #85

Closed mbafford closed 2 years ago

mbafford commented 2 years ago

Add mention of needing to run playwright install if contributing/testing changes.

The pytest tests don't clearly state why they fail if playwright isn't installed.

tests/run_examples.sh does mention it, in the ouput, but I'd expect people to run pytest first.


:books: Documentation preview :books:: https://shot-scraper--85.org.readthedocs.build/en/85/

simonw commented 2 years ago

The workflow does this like so: https://github.com/simonw/shot-scraper/blob/c8686ff9d7a7bc8dc5518cc8048b12399a7d7743/.github/workflows/test.yml#L32-L37

simonw commented 2 years ago

Here's the current error from pytest if Playwright is not installed:

>           assert result.exit_code == 0 #, str(result.exception)
E           assert 1 == 0
E            +  where 1 = <Result Error("Executable doesn't exist at /Users/simon/Library/Caches/ms-playwright/chromium-965416/chrome-mac/Chromi...                                      ║\n╚═════════════════════════════════════════════════════════════════════════╝")>.exit_code

Changing that line to this:

assert result.exit_code == 0, str(result.exception)

Outputs this much better error:

>           assert result.exit_code == 0, str(result.exception)
E           AssertionError: Executable doesn't exist at /Users/simon/Library/Caches/ms-playwright/chromium-965416/chrome-mac/Chromium.app/Contents/MacOS/Chromium
E             ╔═════════════════════════════════════════════════════════════════════════╗
E             ║ Looks like Playwright Test or Playwright was just installed or updated. ║
E             ║ Please run the following command to download new browsers:              ║
E             ║                                                                         ║
E             ║     playwright install                                                  ║
E             ║                                                                         ║
E             ║ <3 Playwright Team                                                      ║
E             ╚═════════════════════════════════════════════════════════════════════════╝
E           assert 1 == 0
E            +  where 1 = <Result Error("Executable doesn't exist at /Users/simon/Library/Caches/ms-playwright/chromium-965416/chrome-mac/Chromi...                                      ║\n╚═════════════════════════════════════════════════════════════════════════╝")>.exit_code