From 0838f518d4f87866ffbaf23780bfc22f4d7ff36a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 21 Jun 2020 14:43:48 +0200 Subject: [PATCH] e2e: save screenshot on failure, upload to github actions --- .github/workflows/ci.yml | 4 ++++ e2e/utils.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5c8d8a8c..1d3144371 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,6 +139,10 @@ jobs: yarn - name: Run coverage run: pipenv run coverage run ./manage.py test --failfast + - uses: actions/upload-artifact@v2 + if: failure() + with: + path: out/ - name: Create XML Report run: pipenv run coverage xml - uses: codecov/codecov-action@v1 diff --git a/e2e/utils.py b/e2e/utils.py index 2683bf1da..2847d9a59 100644 --- a/e2e/utils.py +++ b/e2e/utils.py @@ -1,5 +1,6 @@ """passbook e2e testing utilities""" from functools import lru_cache +from os import makedirs from glob import glob from importlib.util import module_from_spec, spec_from_file_location from inspect import getmembers, isfunction @@ -40,6 +41,7 @@ class SeleniumTestCase(StaticLiveServerTestCase): def setUp(self): super().setUp() + makedirs("out", exist_ok=True) self.driver = self._get_driver() self.driver.maximize_window() self.driver.implicitly_wait(5) @@ -53,6 +55,8 @@ class SeleniumTestCase(StaticLiveServerTestCase): ) def tearDown(self): + if self.failureException: + self.driver.save_screenshot("out/{self.__class__.__name__}.png") self.driver.quit() super().tearDown()