feat(e2e): add screen.tree and screen.debug, print test output without list reporter
Merged
OK
8d ago+292+292+012345678901234567890123456789-14-14-01234567890123456789
What and why
- New
screen.tree()reads the screen once and returns it as text. It uses the same lines and secret redaction as the trace's "Screen at failure".screen.debug()prints that text to the test output. Both work on every engine and are recorded as steps. - On a frame they throw
INVALID_ARGUMENT, and they are left offLocator. No engine can return a subtree yet: web located nodes have no children, and mobile ids change on every capture. - Fix: test
console.logoutput only printed with thelistreporter, so--reporter json/junit/markdown/...dropped it. Now it prints to its own stream. - Fix: with
--reporter json, user output (config top level included) landed on stdout ahead of the report, which broke| jq. User output now goes to stderr, and the json reporter writes to the terminal directly (packages/e2e/src/run/process-output.ts).
test('checkout', async ({ app, screen }) => {
await app.open('/checkout');
await screen.debug();
const tree = await screen.tree();
});
Verified
Ran it locally: yes
- testbed web, scratch test with
console.log+screen.debug(), config logging at top level:
| main | this branch |
|---|---|
--reporter junit: test output missing | hello from the test + tree printed |
--reporter json | jq: parse error, config top level on stdout | stdout parses as the report, user output on stderr |
stdout | |web| tests-scratch/pr/debug.e2e.ts > debug
hello from the test
#root document "Playground"
#n2 navigation "Main"
#n3 link "Home" href="/"
#n4 link "Todos" href="/todos"
- testbed login: the filled password renders as
<secure>, plaintext absent; the trace listsscreen.debugandscreen.treesteps. - iOS simulator, mobile-benchmark:
screen.debug()prints the app tree. Android not run.