Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise_console_error during integration tests #4535

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading