@@ -135,7 +135,7 @@ describe("containers instances", () => {
135135 ) ;
136136 } ) ;
137137
138- it ( "should list instances as JSON (non-TTY)" , async ( ) => {
138+ it ( "should render a table (non-TTY)" , async ( ) => {
139139 setIsTTY ( false ) ;
140140 setWranglerConfig ( { } ) ;
141141 msw . use (
@@ -156,25 +156,18 @@ describe("containers instances", () => {
156156 ) ;
157157 await runWrangler ( `containers instances ${ APP_ID } ` ) ;
158158 expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
159- const output = JSON . parse ( std . out ) ;
160- expect ( output ) . toHaveLength ( 2 ) ;
161- expect ( output [ 0 ] ) . toEqual ( {
162- id : "11111111-1111-1111-1111-111111111111" ,
163- state : "running" ,
164- location : "sfo06" ,
165- version : 3 ,
166- created : "2025-06-01T10:00:00Z" ,
167- } ) ;
168- expect ( output [ 1 ] ) . toEqual ( {
169- id : "22222222-2222-2222-2222-222222222222" ,
170- state : "provisioning" ,
171- location : "iad01" ,
172- version : 2 ,
173- created : "2025-06-01T11:00:00Z" ,
174- } ) ;
159+ expect ( std . out ) . toMatchInlineSnapshot ( `
160+ "┌─┬─┬─┬─┬─┐
161+ │ INSTANCE │ STATE │ LOCATION │ VERSION │ CREATED │
162+ ├─┼─┼─┼─┼─┤
163+ │ 11111111-1111-1111-1111-111111111111 │ running │ sfo06 │ 3 │ 2025-06-01T10:00:00Z │
164+ ├─┼─┼─┼─┼─┤
165+ │ 22222222-2222-2222-2222-222222222222 │ provisioning │ iad01 │ 2 │ 2025-06-01T11:00:00Z │
166+ └─┴─┴─┴─┴─┘"
167+ ` ) ;
175168 } ) ;
176169
177- it ( "should show DO instance IDs and names for DO-backed apps (non-TTY)" , async ( ) => {
170+ it ( "should render DO instance table (non-TTY)" , async ( ) => {
178171 setIsTTY ( false ) ;
179172 setWranglerConfig ( { } ) ;
180173 msw . use (
@@ -193,26 +186,31 @@ describe("containers instances", () => {
193186 )
194187 ) ;
195188 await runWrangler ( `containers instances ${ APP_ID } ` ) ;
196- const output = JSON . parse ( std . out ) ;
197- expect ( output ) . toHaveLength ( 2 ) ;
198- // First row: DO with a running deployment
199- expect ( output [ 0 ] ) . toEqual ( {
200- id : "do-instance-1111" ,
201- name : "random-76" ,
202- state : "running" ,
203- location : "dfw01" ,
204- version : 57 ,
205- created : "2025-06-01T10:00:00Z" ,
206- } ) ;
207- // Second row: DO without a running deployment (inactive)
208- expect ( output [ 1 ] ) . toEqual ( {
209- id : "do-instance-2222" ,
210- name : "random-88" ,
211- state : "inactive" ,
212- location : null ,
213- version : null ,
214- created : "2025-05-26T10:00:00Z" ,
215- } ) ;
189+ expect ( std . out ) . toMatchInlineSnapshot ( `
190+ "┌─┬─┬─┬─┬─┬─┐
191+ │ INSTANCE │ NAME │ STATE │ LOCATION │ VERSION │ CREATED │
192+ ├─┼─┼─┼─┼─┼─┤
193+ │ do-instance-1111 │ random-76 │ running │ dfw01 │ 57 │ 2025-06-01T10:00:00Z │
194+ ├─┼─┼─┼─┼─┼─┤
195+ │ do-instance-2222 │ random-88 │ inactive │ - │ - │ 2025-05-26T10:00:00Z │
196+ └─┴─┴─┴─┴─┴─┘"
197+ ` ) ;
198+ } ) ;
199+
200+ it ( "should reject --per-page 0" , async ( ) => {
201+ setIsTTY ( false ) ;
202+ setWranglerConfig ( { } ) ;
203+ await expect (
204+ runWrangler ( `containers instances ${ APP_ID } --per-page 0` )
205+ ) . rejects . toThrowError ( / - - p e r - p a g e m u s t b e a t l e a s t 1 / ) ;
206+ } ) ;
207+
208+ it ( "should reject --per-page with negative value" , async ( ) => {
209+ setIsTTY ( false ) ;
210+ setWranglerConfig ( { } ) ;
211+ await expect (
212+ runWrangler ( `containers instances ${ APP_ID } --per-page -1` )
213+ ) . rejects . toThrowError ( / - - p e r - p a g e m u s t b e a t l e a s t 1 / ) ;
216214 } ) ;
217215
218216 it ( "should error on invalid ID format" , async ( ) => {
@@ -286,10 +284,9 @@ describe("containers instances", () => {
286284 ) ;
287285 await runWrangler ( `containers instances ${ APP_ID } ` ) ;
288286 expect ( requestCount ) . toBe ( 1 ) ;
289- const output = JSON . parse ( std . out ) ;
290- expect ( output ) . toHaveLength ( 2 ) ;
291- expect ( output [ 0 ] . id ) . toBe ( "11111111-1111-1111-1111-111111111111" ) ;
292- expect ( output [ 1 ] . id ) . toBe ( "22222222-2222-2222-2222-222222222222" ) ;
287+ // Table output should contain both instances
288+ expect ( std . out ) . toContain ( "11111111-1111-1111-1111-111111111111" ) ;
289+ expect ( std . out ) . toContain ( "22222222-2222-2222-2222-222222222222" ) ;
293290 } ) ;
294291
295292 describe ( "--json" , ( ) => {
0 commit comments