-
Notifications
You must be signed in to change notification settings - Fork 100
Add testing API for py-shiny #1156
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
Comments
Hi @pstorozenko 👋 ! @karangattu and I are aiming for a testing release near conf in the early fall. We are hoping to have the existing classes (and their methods) documented and moved under It seems reasonable to try to make basic testing possible in the near future (knowing the API might change), such as the simple UI test linked above. (Functions related to The other helper |
Great to hear that! |
For all those wanting to test your apps right now It's great that there's an Epic for testing shiny apps 🎉 For adding tests to the CI/CD pipeline you can use this snippet in import threading
import pytest
import requests
from tenacity import retry, stop_after_delay, wait_fixed
from uvicorn import Config, Server
APP_HOST = "127.0.0.1"
APP_PORT = 8989
APP_URL = f"http://{APP_HOST}:{APP_PORT}"
@retry(wait=wait_fixed(0.5), stop=stop_after_delay(10))
def wait_for_server_to_start(url):
response = requests.get(url) # noqa: S113
response.raise_for_status() # Will raise an exception if the request is unsuccessful, i.e. server is not ready
def run_server():
config = Config(app="app:app", host=APP_HOST, port=APP_PORT, log_level="info")
server = Server(config)
server.run()
@pytest.fixture(scope="session", autouse=True)
def _shiny_server():
# Start the server in a background thread
thread = threading.Thread(target=run_server, daemon=True)
thread.start()
wait_for_server_to_start(APP_URL)
return |
Hi!
Right now, it's very hard to test the shiny part of your dashboard.
While the internals of py-shiny are tested with
playwright
, the testing API withShinyAppProc
and more is not in the package.I'm keeping my fingers crossed for a quick release of
shiny.testing
namespace as it would allow us creating testable (i.e. enterprise ready) shiny apps in python, just like in R. :)Any ideas when to expect this feature?
Correct me if I'm wrong, but there's no issue on GH that tracks the progress of testing namespace, hence I created this one.
Relevant links:
#testing
channelThe text was updated successfully, but these errors were encountered: