Add a test mode for the web backend
- Dominant language
- Python
- Stars
- 3.3k
- Forks
- 549
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 40
Description
### What is the problem or limitation you are having?
`--test` mode is supported on `briefcase run` on every platform *except* web. We need the ability to run test suites on web so that an app can validate runtime behavior on web.
### Describe the solution you'd like
A default Briefcase `helloworld` project should produce test output from `briefcase run web --test`.
### Describe alternatives you've considered
Don't test on web. YOLO. :-)
### Additional context
There are 2 major technical problems to be solved:
1. Passing in a different app startup arg to the PyScript startup (i.e., running `python -m tests.myapp` rather than `python -m myapp`)
2. Reading test output outside the browser
(1) could be solved by:
- re-writing index.html for test mode
- making index.html reference an external configuration source (e.g., a variable in pyscript.toml) when looking for the startup module
- Making the startup script something that is a file on disk, rather than something embedded in index.html
(2) is more complex - we need to be able to capture anything written to stdout by Python in the browser, and redirect it to a location that Briefcase can see. Some options:
- Have the test harness in the browser open a web socket on a different URL on the server that Briefcase starts, and use *that* for communication between Briefcase and the test suite.
- Install a handler in Python to redirect stdout to a socket, and adding a separate server to Briefcase to read that content
- Use a headless browser or browser test framework (e.g., Playwright, Selenium) that outputs the javascript console to stdout
- Keep the test content *in* the browser (maybe opening a separate window to report test progress); but provide some other external marker signal that Briefcase can read that indicates that the test suite has completed.
Contributor guide
Research direction
Start at the `briefcase run web --test` entry point and compare it with the existing `--test` paths on other platforms; the issue does not name an implementation file or test. Use the default `helloworld` project as the acceptance case, then determine how `index.html` or `pyscript.toml` startup selection and browser stdout or completion signals can be observed outside the browser, with Playwright or Selenium among the stated options.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, testing, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100