Skip to content

Commit d5d41a0

Browse files
authored
raise_console_error during integration tests (#4535)
1 parent 60a5b7b commit d5d41a0

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/integration/conftest.py

+23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import pytest
88

9+
import reflex.app
910
from reflex.config import environment
1011
from reflex.testing import AppHarness, AppHarnessProd
1112

@@ -76,3 +77,25 @@ def app_harness_env(request):
7677
The AppHarness class to use for the test.
7778
"""
7879
return request.param
80+
81+
82+
@pytest.fixture(autouse=True)
83+
def raise_console_error(request, mocker):
84+
"""Spy on calls to `console.error` used by the framework.
85+
86+
Help catch spurious error conditions that might otherwise go unnoticed.
87+
88+
If a test is marked with `ignore_console_error`, the spy will be ignored
89+
after the test.
90+
91+
Args:
92+
request: The pytest request object.
93+
mocker: The pytest mocker object.
94+
95+
Yields:
96+
control to the test function.
97+
"""
98+
spy = mocker.spy(reflex.app.console, "error")
99+
yield
100+
if "ignore_console_error" not in request.keywords:
101+
spy.assert_not_called()

tests/integration/test_exception_handlers.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
from reflex.testing import AppHarness, AppHarnessProd
1515

16+
pytestmark = [pytest.mark.ignore_console_error]
17+
1618

1719
def TestApp():
1820
"""A test app for event exception handler integration."""

0 commit comments

Comments
 (0)