diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4dfbb12ee..0480d106f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -78,7 +78,7 @@ jobs: run: | python -m pytest -v --ignore=tests/benchmarks -m "jstest" tests - check: + check: # This job does nothing and is only used for the branch protection # see https://github.com/marketplace/actions/alls-green#why diff --git a/tests/conftest.py b/tests/conftest.py index 2e0ea0490..24c612c37 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,6 +5,8 @@ import shutil import socket import string +import subprocess +import sys import tempfile from pathlib import Path from typing import Any, Dict @@ -143,37 +145,35 @@ def test_js(self) -> Dict[str, Any]: cypress_config = json.dumps(js_test_config) cypress_config_file = get_abspath("js_test/cypress.config.js") - try: - import subprocess - - # Run the Cypress test command - completed_process = subprocess.run( - [ - "npx", - "cypress", - "run", - # "--browser", - # "chrome", - "--config-file", - rf"{cypress_config_file}", - "--config", - rf"{cypress_config}", - ], - capture_output=True, - ) - - # Send back return code, stdout, and stderr - return { - "returncode": completed_process.returncode, - "stdout": completed_process.stdout, - "stderr": completed_process.stderr, - } - except (Exception, subprocess.CalledProcessError) as e: - return { - "returncode": 1, - "stdout": "", - "stderr": e, - } + # Run the Cypress test command + completed_process = subprocess.run( + [ + "npx", + "cypress", + "run", + # "--browser", + # "chrome", + "--config-file", + rf"{cypress_config_file}", + "--config", + rf"{cypress_config}", + ], + capture_output=True, + ) + + # Send back return code, stdout, and stderr + stdout = completed_process.stdout.decode("utf-8") + stderr = completed_process.stderr.decode("utf-8") + + if completed_process.returncode != 0: + print(stdout) + print(stderr, file=sys.stderr) + + return { + "returncode": completed_process.returncode, + "stdout": stdout, + "stderr": stderr, + } @pytest.fixture(scope="session") diff --git a/tests/test_sn_collapse_button.py b/tests/test_sn_collapse_button.py index 1aa37a23f..05fb1dd9f 100644 --- a/tests/test_sn_collapse_button.py +++ b/tests/test_sn_collapse_button.py @@ -24,7 +24,7 @@ def test_collapse_button_in_variant_doc(test_app, test_server): # Check the return code and stdout assert js_test_result["returncode"] == 0 - assert "All specs passed!" in js_test_result["stdout"].decode("utf-8") + assert "All specs passed!" in js_test_result["stdout"] @pytest.mark.jstest @@ -49,4 +49,4 @@ def test_collapse_button_in_doc_basic(test_app, test_server): # Check the return code and stdout assert js_test_result["returncode"] == 0 - assert "All specs passed!" in js_test_result["stdout"].decode("utf-8") + assert "All specs passed!" in js_test_result["stdout"]