feat(e2e): add screen.tree and screen.debug, print test output without list reporter

Merged
OK
8d ago
+292-14

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 off Locator. No engine can return a subtree yet: web located nodes have no children, and mobile ids change on every capture.
  • Fix: test console.log output only printed with the list reporter, 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:
mainthis branch
--reporter junit: test output missinghello from the test + tree printed
--reporter json | jq: parse error, config top level on stdoutstdout 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 lists screen.debug and screen.tree steps.
  • iOS simulator, mobile-benchmark: screen.debug() prints the app tree. Android not run.