diff --git a/__tests__/lib/cli/format.js b/__tests__/lib/cli/format.js index 09f19a7e5..44c6538a3 100644 --- a/__tests__/lib/cli/format.js +++ b/__tests__/lib/cli/format.js @@ -1,4 +1,4 @@ -import { formatBytes, formatDuration, requoteArgs } from '../../../src/lib/cli/format'; +import { formatBytes, formatDuration, requoteArgs, table } from '../../../src/lib/cli/format'; describe( 'utils/cli/format', () => { describe( 'requoteArgs', () => { @@ -58,6 +58,12 @@ describe( 'utils/cli/format', () => { } ); } ); + describe( 'table', () => { + it( 'should properly format null values', () => { + expect( table( [ { name: 'Hello', value: null } ] ) ).toMatch( /.*Hello.*null.*/i ); + } ); + } ); + describe( 'formatDuration', () => { it( 'should format duration', () => { expect( diff --git a/src/lib/cli/format.ts b/src/lib/cli/format.ts index f08606293..891d364b3 100644 --- a/src/lib/cli/format.ts +++ b/src/lib/cli/format.ts @@ -92,7 +92,7 @@ export function table( data: Record< string, Stringable >[] ): string { } ); data.forEach( datum => { - const row = fields.map( field => datum[ field ].toString() ); + const row = fields.map( field => String( datum[ field ] ) ); dataTable.push( row ); } );