@@ -38,9 +38,8 @@ describe('agent test run-eval', function () {
3838 describe ( 'run-eval with JSON file' , ( ) => {
3939 it ( 'should run evaluation with JSON payload file' , async ( ) => {
4040 const command = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --target-org ${ getUsername ( ) } --json` ;
41- const output = execCmd < RunEvalResult > ( command , {
42- ensureExitCode : 0 ,
43- } ) . jsonOutput ;
41+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
42+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
4443
4544 expect ( output ?. result ) . to . be . ok ;
4645 expect ( output ?. result . tests ) . to . be . an ( 'array' ) ;
@@ -54,9 +53,8 @@ describe('agent test run-eval', function () {
5453
5554 it ( 'should run evaluation with normalized payload' , async ( ) => {
5655 const command = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --target-org ${ getUsername ( ) } --json` ;
57- const output = execCmd < RunEvalResult > ( command , {
58- ensureExitCode : 0 ,
59- } ) . jsonOutput ;
56+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
57+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
6058
6159 expect ( output ?. result . tests [ 0 ] ) . to . be . ok ;
6260 expect ( output ?. result . tests [ 0 ] . id ) . to . equal ( 'test-topic-routing' ) ;
@@ -68,9 +66,8 @@ describe('agent test run-eval', function () {
6866 describe ( 'run-eval with YAML file' , ( ) => {
6967 it ( 'should run evaluation with YAML test spec file' , async ( ) => {
7068 const command = `agent test run-eval --spec ${ yamlSpecPath } --target-org ${ getUsername ( ) } --json` ;
71- const output = execCmd < RunEvalResult > ( command , {
72- ensureExitCode : 0 ,
73- } ) . jsonOutput ;
69+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
70+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
7471
7572 expect ( output ?. result ) . to . be . ok ;
7673 expect ( output ?. result . tests ) . to . be . an ( 'array' ) ;
@@ -80,9 +77,8 @@ describe('agent test run-eval', function () {
8077
8178 it ( 'should auto-infer agent name from YAML subjectName' , async ( ) => {
8279 const command = `agent test run-eval --spec ${ yamlSpecPath } --target-org ${ getUsername ( ) } --json` ;
83- const output = execCmd < RunEvalResult > ( command , {
84- ensureExitCode : 0 ,
85- } ) . jsonOutput ;
80+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
81+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
8682
8783 // Should succeed without explicit --api-name flag
8884 expect ( output ?. result ) . to . be . ok ;
@@ -92,23 +88,19 @@ describe('agent test run-eval', function () {
9288
9389 describe ( 'run-eval with stdin' , ( ) => {
9490 it ( 'should run evaluation with JSON payload from stdin' , async ( ) => {
95- const command = `cat ${ jsonPayloadPath } | sf agent test run-eval --spec - --api-name Local_Info_Agent --target-org ${ getUsername ( ) } --json` ;
96- const output = execCmd < RunEvalResult > ( command , {
97- ensureExitCode : 0 ,
98- cli : 'sf' ,
99- } ) . jsonOutput ;
91+ const command = `cat ${ jsonPayloadPath } | ./bin/run.js agent test run-eval --spec - --api-name Local_Info_Agent --target-org ${ getUsername ( ) } --json` ;
92+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
93+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
10094
10195 expect ( output ?. result ) . to . be . ok ;
10296 expect ( output ?. result . tests ) . to . be . an ( 'array' ) ;
10397 expect ( output ?. result . tests . length ) . to . be . greaterThan ( 0 ) ;
10498 } ) ;
10599
106100 it ( 'should run evaluation with YAML spec from stdin' , async ( ) => {
107- const command = `cat ${ yamlSpecPath } | sf agent test run-eval --spec - --target-org ${ getUsername ( ) } --json` ;
108- const output = execCmd < RunEvalResult > ( command , {
109- ensureExitCode : 0 ,
110- cli : 'sf' ,
111- } ) . jsonOutput ;
101+ const command = `cat ${ yamlSpecPath } | ./bin/run.js agent test run-eval --spec - --target-org ${ getUsername ( ) } --json` ;
102+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
103+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
112104
113105 expect ( output ?. result ) . to . be . ok ;
114106 expect ( output ?. result . tests ) . to . be . an ( 'array' ) ;
@@ -119,47 +111,39 @@ describe('agent test run-eval', function () {
119111 describe ( 'run-eval with flags' , ( ) => {
120112 it ( 'should respect --no-normalize flag' , async ( ) => {
121113 const command = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --no-normalize --target-org ${ getUsername ( ) } --json` ;
122- const output = execCmd < RunEvalResult > ( command , {
123- ensureExitCode : 0 ,
124- } ) . jsonOutput ;
114+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
115+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
125116
126117 expect ( output ?. result ) . to . be . ok ;
127118 expect ( output ?. result . tests ) . to . be . an ( 'array' ) ;
128119 } ) ;
129120
130121 it ( 'should use custom batch size' , async ( ) => {
131122 const command = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --batch-size 1 --target-org ${ getUsername ( ) } --json` ;
132- const output = execCmd < RunEvalResult > ( command , {
133- ensureExitCode : 0 ,
134- } ) . jsonOutput ;
123+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
124+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
135125
136126 expect ( output ?. result ) . to . be . ok ;
137127 expect ( output ?. result . tests ) . to . be . an ( 'array' ) ;
138128 } ) ;
139129
140130 it ( 'should support different result formats' , async ( ) => {
141- // Test human format (default)
131+ // Test human format (default) - don't enforce exit code since tests may fail
142132 const humanCommand = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --result-format human --target-org ${ getUsername ( ) } ` ;
143- const humanOutput = execCmd ( humanCommand , {
144- ensureExitCode : 0 ,
145- } ) . shellOutput . stdout ;
133+ const humanOutput = execCmd ( humanCommand ) . shellOutput . stdout ;
146134
147135 expect ( humanOutput ) . to . be . ok ;
148136 expect ( humanOutput ) . to . be . a ( 'string' ) ;
149137
150- // Test tap format
138+ // Test tap format - don't enforce exit code since tests may fail
151139 const tapCommand = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --result-format tap --target-org ${ getUsername ( ) } ` ;
152- const tapOutput = execCmd ( tapCommand , {
153- ensureExitCode : 0 ,
154- } ) . shellOutput . stdout ;
140+ const tapOutput = execCmd ( tapCommand ) . shellOutput . stdout ;
155141
156142 expect ( tapOutput ) . to . include ( 'TAP version' ) ;
157143
158- // Test junit format
144+ // Test junit format - don't enforce exit code since tests may fail
159145 const junitCommand = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --result-format junit --target-org ${ getUsername ( ) } ` ;
160- const junitOutput = execCmd ( junitCommand , {
161- ensureExitCode : 0 ,
162- } ) . shellOutput . stdout ;
146+ const junitOutput = execCmd ( junitCommand ) . shellOutput . stdout ;
163147
164148 expect ( junitOutput ) . to . include ( '<?xml' ) ;
165149 expect ( junitOutput ) . to . include ( 'testsuite' ) ;
@@ -172,42 +156,44 @@ describe('agent test run-eval', function () {
172156 const command = `agent test run-eval --spec ${ invalidJson } --api-name Local_Info_Agent --target-org ${ getUsername ( ) } --json` ;
173157
174158 try {
175- execCmd < RunEvalResult > ( command ) ;
159+ execCmd < RunEvalResult > ( command , { ensureExitCode : 0 } ) ;
176160 expect . fail ( 'Should have thrown an error for invalid JSON' ) ;
177161 } catch ( error ) {
178- expect ( ( error as Error ) . message ) . to . include ( 'exit code' ) ;
162+ // Command should fail with non-zero exit code
163+ expect ( ( error as Error ) . message ) . to . match ( / e x i t c o d e | I n v a l i d t e s t p a y l o a d / i) ;
179164 }
180165 } ) ;
181166
182167 it ( 'should fail when agent not found' , async ( ) => {
183168 const command = `agent test run-eval --spec ${ jsonPayloadPath } --api-name NonExistentAgent --target-org ${ getUsername ( ) } --json` ;
184169
185170 try {
186- execCmd < RunEvalResult > ( command ) ;
171+ execCmd < RunEvalResult > ( command , { ensureExitCode : 0 } ) ;
187172 expect . fail ( 'Should have thrown an error for non-existent agent' ) ;
188173 } catch ( error ) {
189- expect ( ( error as Error ) . message ) . to . include ( 'exit code' ) ;
174+ // Command should fail with non-zero exit code
175+ expect ( ( error as Error ) . message ) . to . match ( / e x i t c o d e | a g e n t .* n o t f o u n d / i) ;
190176 }
191177 } ) ;
192178
193179 it ( 'should require --spec flag' , async ( ) => {
194180 const command = `agent test run-eval --api-name Local_Info_Agent --target-org ${ getUsername ( ) } --json` ;
195181
196182 try {
197- execCmd < RunEvalResult > ( command ) ;
183+ execCmd < RunEvalResult > ( command , { ensureExitCode : 0 } ) ;
198184 expect . fail ( 'Should have thrown an error for missing --spec' ) ;
199185 } catch ( error ) {
200- expect ( ( error as Error ) . message ) . to . include ( 'required' ) ;
186+ // Command should fail due to missing required flag
187+ expect ( ( error as Error ) . message ) . to . match ( / e x i t c o d e | r e q u i r e d | M i s s i n g r e q u i r e d f l a g / i) ;
201188 }
202189 } ) ;
203190 } ) ;
204191
205192 describe ( 'run-eval output structure' , ( ) => {
206193 it ( 'should include test summaries with correct structure' , async ( ) => {
207194 const command = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --target-org ${ getUsername ( ) } --json` ;
208- const output = execCmd < RunEvalResult > ( command , {
209- ensureExitCode : 0 ,
210- } ) . jsonOutput ;
195+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
196+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
211197
212198 expect ( output ?. result . tests ) . to . be . an ( 'array' ) ;
213199 const firstTest = output ?. result . tests [ 0 ] ;
@@ -219,9 +205,8 @@ describe('agent test run-eval', function () {
219205
220206 it ( 'should include summary with all metrics' , async ( ) => {
221207 const command = `agent test run-eval --spec ${ jsonPayloadPath } --api-name Local_Info_Agent --target-org ${ getUsername ( ) } --json` ;
222- const output = execCmd < RunEvalResult > ( command , {
223- ensureExitCode : 0 ,
224- } ) . jsonOutput ;
208+ // Don't enforce exit code 0 since the command exits with 1 if tests fail
209+ const output = execCmd < RunEvalResult > ( command ) . jsonOutput ;
225210
226211 const summary = output ?. result . summary ;
227212 expect ( summary ) . to . have . property ( 'passed' ) ;
0 commit comments