@@ -5,6 +5,52 @@ import os from 'node:os';
55import path from 'node:path' ;
66import { runCliCapture } from './cli-capture.ts' ;
77
8+ function makeFailedReplayResult ( ) {
9+ return {
10+ file : '/tmp/02-fail.ad' ,
11+ session : 'default:test:suite:2' ,
12+ status : 'failed' ,
13+ durationMs : 5 ,
14+ attempts : 2 ,
15+ artifactsDir : '/tmp/test-artifacts/02-fail' ,
16+ error : { message : 'Replay failed at step 1 (open Demo): boom' } ,
17+ } ;
18+ }
19+
20+ function makeReplaySuiteResponse ( ) {
21+ const failedReplayResult = makeFailedReplayResult ( ) ;
22+
23+ return {
24+ ok : true as const ,
25+ data : {
26+ total : 3 ,
27+ executed : 2 ,
28+ passed : 1 ,
29+ failed : 1 ,
30+ skipped : 1 ,
31+ notRun : 0 ,
32+ durationMs : 25 ,
33+ failures : [ failedReplayResult ] ,
34+ tests : [
35+ {
36+ file : '/tmp/01-pass.ad' ,
37+ session : 'default:test:suite:1' ,
38+ status : 'passed' ,
39+ durationMs : 10 ,
40+ attempts : 1 ,
41+ } ,
42+ failedReplayResult ,
43+ {
44+ file : '/tmp/03-skip.ad' ,
45+ status : 'skipped' ,
46+ durationMs : 0 ,
47+ message : 'missing platform metadata for --platform android' ,
48+ } ,
49+ ] ,
50+ } ,
51+ } ;
52+ }
53+
854test ( 'network dump prints parsed entries and metadata' , async ( ) => {
955 const result = await runCliCapture ( [ 'network' , 'dump' , '10' , '--include' , 'all' ] , async ( ) => ( {
1056 ok : true ,
@@ -53,53 +99,7 @@ test('network dump prints parsed entries and metadata', async () => {
5399} ) ;
54100
55101test ( 'test command prints suite summary and exits non-zero on failures' , async ( ) => {
56- const result = await runCliCapture ( [ 'test' , './suite' ] , async ( ) => ( {
57- ok : true ,
58- data : {
59- total : 3 ,
60- executed : 2 ,
61- passed : 1 ,
62- failed : 1 ,
63- skipped : 1 ,
64- notRun : 0 ,
65- durationMs : 25 ,
66- failures : [
67- {
68- file : '/tmp/02-fail.ad' ,
69- session : 'default:test:suite:2' ,
70- status : 'failed' ,
71- durationMs : 5 ,
72- attempts : 2 ,
73- artifactsDir : '/tmp/test-artifacts/02-fail' ,
74- error : { message : 'Replay failed at step 1 (open Demo): boom' } ,
75- } ,
76- ] ,
77- tests : [
78- {
79- file : '/tmp/01-pass.ad' ,
80- session : 'default:test:suite:1' ,
81- status : 'passed' ,
82- durationMs : 10 ,
83- attempts : 1 ,
84- } ,
85- {
86- file : '/tmp/02-fail.ad' ,
87- session : 'default:test:suite:2' ,
88- status : 'failed' ,
89- durationMs : 5 ,
90- attempts : 2 ,
91- artifactsDir : '/tmp/test-artifacts/02-fail' ,
92- error : { message : 'Replay failed at step 1 (open Demo): boom' } ,
93- } ,
94- {
95- file : '/tmp/03-skip.ad' ,
96- status : 'skipped' ,
97- durationMs : 0 ,
98- message : 'missing platform metadata for --platform android' ,
99- } ,
100- ] ,
101- } ,
102- } ) ) ;
102+ const result = await runCliCapture ( [ 'test' , './suite' ] , async ( ) => makeReplaySuiteResponse ( ) ) ;
103103
104104 assert . equal ( result . code , 1 ) ;
105105 assert . equal ( result . calls . length , 1 ) ;
@@ -113,53 +113,9 @@ test('test command prints suite summary and exits non-zero on failures', async (
113113} ) ;
114114
115115test ( 'test command --verbose prints all test statuses' , async ( ) => {
116- const result = await runCliCapture ( [ 'test' , './suite' , '--verbose' ] , async ( ) => ( {
117- ok : true ,
118- data : {
119- total : 3 ,
120- executed : 2 ,
121- passed : 1 ,
122- failed : 1 ,
123- skipped : 1 ,
124- notRun : 0 ,
125- durationMs : 25 ,
126- failures : [
127- {
128- file : '/tmp/02-fail.ad' ,
129- session : 'default:test:suite:2' ,
130- status : 'failed' ,
131- durationMs : 5 ,
132- attempts : 2 ,
133- artifactsDir : '/tmp/test-artifacts/02-fail' ,
134- error : { message : 'Replay failed at step 1 (open Demo): boom' } ,
135- } ,
136- ] ,
137- tests : [
138- {
139- file : '/tmp/01-pass.ad' ,
140- session : 'default:test:suite:1' ,
141- status : 'passed' ,
142- durationMs : 10 ,
143- attempts : 1 ,
144- } ,
145- {
146- file : '/tmp/02-fail.ad' ,
147- session : 'default:test:suite:2' ,
148- status : 'failed' ,
149- durationMs : 5 ,
150- attempts : 2 ,
151- artifactsDir : '/tmp/test-artifacts/02-fail' ,
152- error : { message : 'Replay failed at step 1 (open Demo): boom' } ,
153- } ,
154- {
155- file : '/tmp/03-skip.ad' ,
156- status : 'skipped' ,
157- durationMs : 0 ,
158- message : 'missing platform metadata for --platform android' ,
159- } ,
160- ] ,
161- } ,
162- } ) ) ;
116+ const result = await runCliCapture ( [ 'test' , './suite' , '--verbose' ] , async ( ) =>
117+ makeReplaySuiteResponse ( ) ,
118+ ) ;
163119
164120 assert . equal ( result . code , 1 ) ;
165121 assert . match ( result . stderr , / R u n n i n g r e p l a y s u i t e \. \. \. / ) ;
0 commit comments