Skip to content

Commit

Permalink
raise_console_error during integration tests (#4535)
Browse files Browse the repository at this point in the history
  • Loading branch information
masenf authored Dec 12, 2024
1 parent 60a5b7b commit d5d41a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest

import reflex.app
from reflex.config import environment
from reflex.testing import AppHarness, AppHarnessProd

Expand Down Expand Up @@ -76,3 +77,25 @@ def app_harness_env(request):
The AppHarness class to use for the test.
"""
return request.param


@pytest.fixture(autouse=True)
def raise_console_error(request, mocker):
"""Spy on calls to `console.error` used by the framework.
Help catch spurious error conditions that might otherwise go unnoticed.
If a test is marked with `ignore_console_error`, the spy will be ignored
after the test.
Args:
request: The pytest request object.
mocker: The pytest mocker object.
Yields:
control to the test function.
"""
spy = mocker.spy(reflex.app.console, "error")
yield
if "ignore_console_error" not in request.keywords:
spy.assert_not_called()
2 changes: 2 additions & 0 deletions tests/integration/test_exception_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

from reflex.testing import AppHarness, AppHarnessProd

pytestmark = [pytest.mark.ignore_console_error]


def TestApp():
"""A test app for event exception handler integration."""
Expand Down

0 comments on commit d5d41a0

Please sign in to comment.