@@ -1229,36 +1229,19 @@ describe('embeded functions select', () => {
12291229 // test select the created_ago embeded function
12301230 test ( 'select the created_ago embeded function' , async ( ) => {
12311231 const res = await postgrest . from ( 'users_audit' ) . select ( 'id, created_ago' )
1232- expect ( res ) . toMatchInlineSnapshot ( `
1233- Object {
1234- "count": null,
1235- "data": Array [
1236- Object {
1237- "created_ago": 7,
1238- "id": 1,
1239- },
1240- Object {
1241- "created_ago": 7,
1242- "id": 2,
1243- },
1244- Object {
1245- "created_ago": 7,
1246- "id": 3,
1247- },
1248- Object {
1249- "created_ago": 7,
1250- "id": 4,
1251- },
1252- Object {
1253- "created_ago": 7,
1254- "id": 5,
1255- },
1256- ],
1257- "error": null,
1258- "status": 200,
1259- "statusText": "OK",
1260- }
1261- ` )
1232+ // Don't snapshot time-based values - they change daily and cause flaky tests
1233+ expect ( res . error ) . toBeNull ( )
1234+ expect ( res . status ) . toBe ( 200 )
1235+ expect ( res . statusText ) . toBe ( 'OK' )
1236+ expect ( res . count ) . toBeNull ( )
1237+ expect ( res . data ) . toHaveLength ( 5 )
1238+ // Verify structure of each record
1239+ expect ( res . data ?. [ 0 ] ) . toMatchObject ( {
1240+ id : expect . any ( Number ) ,
1241+ created_ago : expect . any ( Number ) ,
1242+ } )
1243+ // Verify time-based value is reasonable
1244+ expect ( res . data ?. [ 0 ] . created_ago ) . toBeGreaterThanOrEqual ( 0 )
12621245 let result : Exclude < typeof res . data , null >
12631246 const ExpectedSchema = z . array (
12641247 z . object ( {
@@ -1271,7 +1254,7 @@ describe('embeded functions select', () => {
12711254 expectType < TypeEqual < typeof result , typeof expected > > ( true )
12721255 ExpectedSchema . parse ( res . data )
12731256 const use_rpc_call = await postgrest . rpc ( 'created_ago' , {
1274- // @ts -expect-error - id is not a parameter of the created_ago function
1257+ // @ts -expect-error Object literal may only specify known properties
12751258 id : 1 ,
12761259 } )
12771260 expect ( use_rpc_call ) . toMatchInlineSnapshot ( `
@@ -1301,24 +1284,19 @@ describe('embeded functions select', () => {
13011284 // Test the days_since_event embeded function over partitioned table
13021285 test ( 'select the days_since_event embeded function over partitioned table' , async ( ) => {
13031286 const res = await postgrest . from ( 'events' ) . select ( 'id, days_since_event' )
1304- expect ( res ) . toMatchInlineSnapshot ( `
1305- Object {
1306- "count": null,
1307- "data": Array [
1308- Object {
1309- "days_since_event": 500,
1310- "id": 1,
1311- },
1312- Object {
1313- "days_since_event": 222,
1314- "id": 2,
1315- },
1316- ],
1317- "error": null,
1318- "status": 200,
1319- "statusText": "OK",
1320- }
1321- ` )
1287+ // Don't snapshot time-based values - they change daily and cause flaky tests
1288+ expect ( res . error ) . toBeNull ( )
1289+ expect ( res . status ) . toBe ( 200 )
1290+ expect ( res . statusText ) . toBe ( 'OK' )
1291+ expect ( res . count ) . toBeNull ( )
1292+ expect ( res . data ) . toHaveLength ( 2 )
1293+ // Verify structure of each record
1294+ expect ( res . data ?. [ 0 ] ) . toMatchObject ( {
1295+ id : expect . any ( Number ) ,
1296+ days_since_event : expect . any ( Number ) ,
1297+ } )
1298+ // Verify time-based value is reasonable
1299+ expect ( res . data ?. [ 0 ] . days_since_event ) . toBeGreaterThanOrEqual ( 0 )
13221300 let result : Exclude < typeof res . data , null >
13231301 const ExpectedSchema = z . array (
13241302 z . object ( {
@@ -1331,7 +1309,7 @@ describe('embeded functions select', () => {
13311309 expectType < TypeEqual < typeof result , typeof expected > > ( true )
13321310 ExpectedSchema . parse ( res . data )
13331311 const use_rpc_call = await postgrest . rpc ( 'days_since_event' , {
1334- // @ts -expect-error - id is not a parameter of the days_since_event function
1312+ // @ts -expect-error Object literal may only specify known properties
13351313 id : 1 ,
13361314 } )
13371315 expect ( use_rpc_call ) . toMatchInlineSnapshot ( `
0 commit comments