Skip to content

Commit 0169cbe

Browse files
committed
fix: improve maestro test output
1 parent 37618c9 commit 0169cbe

3 files changed

Lines changed: 28 additions & 14 deletions

File tree

src/__tests__/cli-network.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ test('test command prints suite summary and exits non-zero on failures', async (
106106
assert.equal(result.calls.length, 1);
107107
assert.equal(result.calls[0]?.meta?.requestProgress, 'replay-test');
108108
assert.match(result.stderr, /Running replay suite\.\.\./);
109-
assert.doesNotMatch(result.stdout, /PASS \/tmp\/01-pass\.ad/);
109+
assert.match(result.stdout, /PASS 01-pass\.ad \(0\.01s\)/);
110110
assert.match(
111111
result.stdout,
112112
/FAIL "Checkout failure" in 02-fail\.ad after 2 attempts \(total 0\.005s\)/,
@@ -204,9 +204,9 @@ test('test command --verbose prints step telemetry for passing tests without deb
204204
assert.equal(result.code, null);
205205
assert.equal(result.calls[0]?.meta?.debug, false);
206206
assert.match(result.stdout, /PASS "Authentication flow" \(0\.5s\)/);
207-
assert.match(result.stdout, /steps \(attempt 1\):/);
208-
assert.match(result.stdout, /\[ok\] tapOn "text=\\"Log in\\"" \(line 3, 0\.25s\)/);
209-
assert.match(result.stdout, /\[ok\] assertVisible "text=\\"Home\\"" \(line 4, 0\.075s\)/);
207+
assert.match(result.stdout, /steps:/);
208+
assert.match(result.stdout, /tapOn "text=\\"Log in\\"" \(line 3, 0\.25s\)/);
209+
assert.match(result.stdout, /assertVisible "text=\\"Home\\"" \(line 4, 0\.075s\)/);
210210
} finally {
211211
await fs.rm(tmpDir, { recursive: true, force: true });
212212
}
@@ -248,6 +248,10 @@ test('test command reports flaky passed-on-retry cases in the default summary',
248248
assert.equal(result.code, null);
249249
assert.match(result.stderr, /Running replay suite\.\.\./);
250250
assert.doesNotMatch(result.stdout, /FLAKY/);
251+
assert.match(
252+
result.stdout,
253+
/PASS "Authentication flow" after 2 attempts \(passed attempt 17\.5s, total 112\.2s\)/,
254+
);
251255
assert.match(result.stdout, /Test summary: 1 passed, 0 failed, 1 flaky in 0\.025s/);
252256
assert.match(result.stdout, /Flaky tests:/);
253257
assert.match(
@@ -336,10 +340,7 @@ test('test command prints failed attempt step telemetry when timing trace exists
336340

337341
assert.equal(result.code, 1);
338342
assert.match(result.stdout, /steps \(attempt 2\):/);
339-
assert.match(
340-
result.stdout,
341-
/\[ok\] open "Demo" \(line 3, 0\.125s, timing \{"launchMs":100\}\)/,
342-
);
343+
assert.match(result.stdout, /open "Demo" \(line 3, 0\.125s, timing \{"launchMs":100\}\)/);
343344
assert.match(
344345
result.stdout,
345346
/\[FAIL\] tapOn "text=\\"Pay\\"" \(line 4, 1\.50s, ASSERTION_FAILED\)/,
@@ -381,6 +382,7 @@ test('test --maestro forwards Maestro backend and platform for directory suites'
381382
assert.deepEqual(result.calls[0]?.positionals, [tmpDir]);
382383
assert.equal(result.calls[0]?.flags?.replayBackend, 'maestro');
383384
assert.equal(result.calls[0]?.flags?.platform, 'android');
385+
assert.equal(result.calls[0]?.meta?.requestProgress, undefined);
384386
assert.match(result.stderr, /Running replay suite\.\.\./);
385387
} finally {
386388
await fs.rm(tmpDir, { recursive: true, force: true });

src/cli-test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ function renderReplayTestSummary(
3737
renderVerboseTestResult(entry);
3838
}
3939
} else {
40-
for (const entry of data.failures) {
41-
renderFailedTestResult(entry);
40+
for (const entry of data.tests) {
41+
renderDefaultTestResult(entry);
4242
}
4343
}
4444

@@ -52,6 +52,18 @@ function renderReplayTestSummary(
5252
return getReplayTestExitCode(data);
5353
}
5454

55+
function renderDefaultTestResult(result: ReplaySuiteTestResult): void {
56+
if (result.status === 'failed') {
57+
renderFailedTestResult(result);
58+
return;
59+
}
60+
if (result.status !== 'passed') return;
61+
62+
process.stdout.write(
63+
`PASS ${replayTestDisplayName(result)}${formatReplayTestDurationSuffix(result)}\n`,
64+
);
65+
}
66+
5567
function renderVerboseTestResult(result: ReplaySuiteTestResult): void {
5668
if (result.status === 'failed') {
5769
renderFailedTestResult(result);
@@ -139,7 +151,7 @@ function replayTestStepLines(result: ReplaySuiteTestResult): string[] {
139151
if (stops.length === 0) return [];
140152

141153
return [
142-
`steps (attempt ${result.attempts}):`,
154+
result.attempts > 1 ? `steps (attempt ${result.attempts}):` : 'steps:',
143155
...stops.map((stop) => renderReplayStepTrace(stop, starts.get(stop.step))),
144156
];
145157
}
@@ -211,8 +223,8 @@ function renderReplayStepTrace(
211223
start: ReplayActionStartTrace | undefined,
212224
): string {
213225
const failed = stop.ok === false;
214-
const status = failed ? '[FAIL]' : stop.ok === true ? '[ok]' : '[info]';
215-
return ` ${status} ${formatReplayStepCommand(start, stop)}${formatReplayStepDetails(stop, start)}`;
226+
const status = failed ? '[FAIL] ' : stop.ok === true ? '' : '[info] ';
227+
return ` ${status}${formatReplayStepCommand(start, stop)}${formatReplayStepDetails(stop, start)}`;
216228
}
217229

218230
function formatReplayStepDetails(

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ function createCliDaemonTransport(options: {
509509
transport: AgentDeviceDaemonTransport;
510510
}): AgentDeviceDaemonTransport {
511511
const { command, flags, transport } = options;
512-
if (command !== 'test' || flags.json) return transport;
512+
if (command !== 'test' || flags.json || flags.replayMaestro) return transport;
513513
return async (req) =>
514514
await transport({
515515
...req,

0 commit comments

Comments
 (0)