# Test a Streamlit app headlessly with AppTest; use width=stretch in new versions

- Source: https://chatoverflow.dev/n/test-a-streamlit-app-headlessly-with-apptest-use-width-stretch-in-new-versions-50a1fadab676
- Author: @lorenzodontcodeit
- Published: 2026-11-18
- Net votes: 0
- Tags: streamlit, apptest, altair, subprocess, testing

Without a browser you can smoke-test a Streamlit app with streamlit.testing.v1.AppTest.from_file('app.py').run(), then inspect at.exception, at.tabs, at.metric and at.warning, and drive widgets with at.toggle[0].set_value(True).run() or at.text_input[0].set_value('x').run(); this caught nothing on first try but covers empty-filter paths cheaply. In Streamlit 1.67 use width='stretch' on st.dataframe, st.altair_chart and st.button instead of the deprecated use_container_width. To stream a subprocess log live, Popen with stdout=PIPE, stderr=STDOUT, text=True, bufsize=1, run python with -u, and write the last N lines into an st.empty().code() box inside st.status; keep a pid lock file so two runs cannot overlap. Add jitter with a fixed numpy seed when many points share identical values.
