@@ -4,7 +4,7 @@ import v8 from 'v8';
4
4
import { readFileSync } from 'node:fs' ;
5
5
import * as grpc from '@grpc/grpc-js' ;
6
6
import asyncRetry from 'async-retry' ;
7
- import anyTest , { Implementation , TestInterface } from 'ava' ;
7
+ import anyTest , { Implementation , TestFn } from 'ava' ;
8
8
import dedent from 'dedent' ;
9
9
import ms from 'ms' ;
10
10
import { v4 as uuid4 } from 'uuid' ;
@@ -66,10 +66,10 @@ export interface Context {
66
66
runPromise : Promise < void > ;
67
67
}
68
68
69
- const _test = anyTest as TestInterface < Context > ;
69
+ const _test = anyTest as TestFn < Context > ;
70
70
71
71
export function runIntegrationTests ( codec ?: PayloadCodec ) : void {
72
- const test = ( name : string , fn : Implementation < Context > ) => _test ( codec ? 'With codec—' + name : name , fn ) ;
72
+ const test = ( name : string , fn : Implementation < [ ] , Context > ) => _test ( codec ? 'With codec—' + name : name , fn ) ;
73
73
const dataConverter = { payloadCodecs : codec ? [ codec ] : [ ] } ;
74
74
const loadedDataConverter = {
75
75
payloadConverter : defaultPayloadConverter ,
@@ -236,7 +236,7 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
236
236
237
237
test ( 'activity-failure with Error' , async ( t ) => {
238
238
const { client } = t . context ;
239
- const err : WorkflowFailedError = await t . throwsAsync (
239
+ const err : WorkflowFailedError | undefined = await t . throwsAsync (
240
240
client . execute ( workflows . activityFailure , {
241
241
taskQueue : 'test' ,
242
242
workflowId : uuid4 ( ) ,
@@ -246,8 +246,8 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
246
246
instanceOf : WorkflowFailedError ,
247
247
}
248
248
) ;
249
- t . is ( err . message , 'Workflow execution failed' ) ;
250
- if ( ! ( err . cause instanceof ActivityFailure ) ) {
249
+ t . is ( err ? .message , 'Workflow execution failed' ) ;
250
+ if ( ! ( err ? .cause instanceof ActivityFailure ) ) {
251
251
t . fail ( 'Expected err.cause to be an instance of ActivityFailure' ) ;
252
252
return ;
253
253
}
@@ -260,14 +260,14 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
260
260
cleanOptionalStackTrace ( err . cause . cause . stack ) ,
261
261
dedent `
262
262
Error: Fail me
263
- at Activity.throwAnError [as fn] (test/src/activities/index.ts)
263
+ at Activity.throwAnError (test/src/activities/index.ts)
264
264
`
265
265
) ;
266
266
} ) ;
267
267
268
268
test ( 'activity-failure with ApplicationFailure' , async ( t ) => {
269
269
const { client } = t . context ;
270
- const err : WorkflowFailedError = await t . throwsAsync (
270
+ const err : WorkflowFailedError | undefined = await t . throwsAsync (
271
271
client . execute ( workflows . activityFailure , {
272
272
taskQueue : 'test' ,
273
273
workflowId : uuid4 ( ) ,
@@ -277,8 +277,8 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
277
277
instanceOf : WorkflowFailedError ,
278
278
}
279
279
) ;
280
- t . is ( err . message , 'Workflow execution failed' ) ;
281
- if ( ! ( err . cause instanceof ActivityFailure ) ) {
280
+ t . is ( err ? .message , 'Workflow execution failed' ) ;
281
+ if ( ! ( err ? .cause instanceof ActivityFailure ) ) {
282
282
t . fail ( 'Expected err.cause to be an instance of ActivityFailure' ) ;
283
283
return ;
284
284
}
@@ -294,7 +294,7 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
294
294
dedent `
295
295
ApplicationFailure: Fail me
296
296
at Function.nonRetryable (common/src/failure.ts)
297
- at Activity.throwAnError [as fn] (test/src/activities/index.ts)
297
+ at Activity.throwAnError (test/src/activities/index.ts)
298
298
`
299
299
) ;
300
300
} ) ;
@@ -314,7 +314,7 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
314
314
315
315
test ( 'child-workflow-failure' , async ( t ) => {
316
316
const { client } = t . context ;
317
- const err : WorkflowFailedError = await t . throwsAsync (
317
+ const err : WorkflowFailedError | undefined = await t . throwsAsync (
318
318
client . execute ( workflows . childWorkflowFailure , {
319
319
taskQueue : 'test' ,
320
320
workflowId : uuid4 ( ) ,
@@ -323,7 +323,7 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
323
323
instanceOf : WorkflowFailedError ,
324
324
}
325
325
) ;
326
- if ( ! ( err . cause instanceof ChildWorkflowFailure ) ) {
326
+ if ( ! ( err ? .cause instanceof ChildWorkflowFailure ) ) {
327
327
return t . fail ( 'Expected err.cause to be an instance of ChildWorkflowFailure' ) ;
328
328
}
329
329
if ( ! ( err . cause . cause instanceof ApplicationFailure ) ) {
@@ -354,10 +354,10 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
354
354
}
355
355
const child = client . getHandle ( childExecution . workflowId ! , childExecution . runId ! ) ;
356
356
await child . terminate ( ) ;
357
- const err : WorkflowFailedError = await t . throwsAsync ( workflow . result ( ) , {
357
+ const err : WorkflowFailedError | undefined = await t . throwsAsync ( workflow . result ( ) , {
358
358
instanceOf : WorkflowFailedError ,
359
359
} ) ;
360
- if ( ! ( err . cause instanceof ChildWorkflowFailure ) ) {
360
+ if ( ! ( err ? .cause instanceof ChildWorkflowFailure ) ) {
361
361
return t . fail ( 'Expected err.cause to be an instance of ChildWorkflowFailure' ) ;
362
362
}
363
363
t . is ( err . cause . retryState , RetryState . RETRY_STATE_NON_RETRYABLE_FAILURE ) ;
@@ -368,7 +368,7 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
368
368
369
369
test ( 'child-workflow-timeout' , async ( t ) => {
370
370
const { client } = t . context ;
371
- const err : WorkflowFailedError = await t . throwsAsync (
371
+ const err : WorkflowFailedError | undefined = await t . throwsAsync (
372
372
client . execute ( workflows . childWorkflowTimeout , {
373
373
taskQueue : 'test' ,
374
374
workflowId : uuid4 ( ) ,
@@ -377,7 +377,7 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
377
377
instanceOf : WorkflowFailedError ,
378
378
}
379
379
) ;
380
- if ( ! ( err . cause instanceof ChildWorkflowFailure ) ) {
380
+ if ( ! ( err ? .cause instanceof ChildWorkflowFailure ) ) {
381
381
return t . fail ( 'Expected err.cause to be an instance of ChildWorkflowFailure' ) ;
382
382
}
383
383
t . is ( err . cause . retryState , RetryState . RETRY_STATE_TIMEOUT ) ;
@@ -451,10 +451,10 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
451
451
workflowId : uuid4 ( ) ,
452
452
} ) ;
453
453
await workflow . signal ( workflows . interruptSignal , 'just because' ) ;
454
- const err : WorkflowFailedError = await t . throwsAsync ( workflow . result ( ) , {
454
+ const err : WorkflowFailedError | undefined = await t . throwsAsync ( workflow . result ( ) , {
455
455
instanceOf : WorkflowFailedError ,
456
456
} ) ;
457
- if ( ! ( err . cause instanceof ApplicationFailure ) ) {
457
+ if ( ! ( err ? .cause instanceof ApplicationFailure ) ) {
458
458
return t . fail ( 'Expected err.cause to be an instance of ApplicationFailure' ) ;
459
459
}
460
460
t . is ( err . cause . message , 'just because' ) ;
@@ -467,10 +467,10 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
467
467
workflowId : uuid4 ( ) ,
468
468
} ) ;
469
469
await workflow . signal ( workflows . failSignal ) ;
470
- const err : WorkflowFailedError = await t . throwsAsync ( workflow . result ( ) , {
470
+ const err : WorkflowFailedError | undefined = await t . throwsAsync ( workflow . result ( ) , {
471
471
instanceOf : WorkflowFailedError ,
472
472
} ) ;
473
- if ( ! ( err . cause instanceof ApplicationFailure ) ) {
473
+ if ( ! ( err ? .cause instanceof ApplicationFailure ) ) {
474
474
return t . fail ( 'Expected err.cause to be an instance of ApplicationFailure' ) ;
475
475
}
476
476
t . is ( err . cause . message , 'Signal failed' ) ;
@@ -483,10 +483,10 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
483
483
workflowId : uuid4 ( ) ,
484
484
} ) ;
485
485
await workflow . signal ( workflows . failSignal ) ;
486
- const err : WorkflowFailedError = await t . throwsAsync ( workflow . result ( ) , {
486
+ const err : WorkflowFailedError | undefined = await t . throwsAsync ( workflow . result ( ) , {
487
487
instanceOf : WorkflowFailedError ,
488
488
} ) ;
489
- if ( ! ( err . cause instanceof ApplicationFailure ) ) {
489
+ if ( ! ( err ? .cause instanceof ApplicationFailure ) ) {
490
490
return t . fail ( 'Expected err.cause to be an instance of ApplicationFailure' ) ;
491
491
}
492
492
t . is ( err . cause . message , 'Signal failed' ) ;
@@ -952,21 +952,21 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
952
952
signalArgs : [ 'interrupted from signalWithStart' ] ,
953
953
} ) ;
954
954
{
955
- const err : WorkflowFailedError = await t . throwsAsync ( ogWF . result ( ) , {
955
+ const err : WorkflowFailedError | undefined = await t . throwsAsync ( ogWF . result ( ) , {
956
956
instanceOf : WorkflowFailedError ,
957
957
} ) ;
958
- if ( ! ( err . cause instanceof ApplicationFailure ) ) {
958
+ if ( ! ( err ? .cause instanceof ApplicationFailure ) ) {
959
959
return t . fail ( 'Expected err.cause to be an instance of ApplicationFailure' ) ;
960
960
}
961
961
t . is ( err . cause . message , 'interrupted from signalWithStart' ) ;
962
962
}
963
963
// Test returned runId
964
964
const workflow = client . getHandle < typeof workflows . interruptableWorkflow > ( ogWF . workflowId , ogWF . signaledRunId ) ;
965
965
{
966
- const err : WorkflowFailedError = await t . throwsAsync ( workflow . result ( ) , {
966
+ const err : WorkflowFailedError | undefined = await t . throwsAsync ( workflow . result ( ) , {
967
967
instanceOf : WorkflowFailedError ,
968
968
} ) ;
969
- if ( ! ( err . cause instanceof ApplicationFailure ) ) {
969
+ if ( ! ( err ? .cause instanceof ApplicationFailure ) ) {
970
970
return t . fail ( 'Expected err.cause to be an instance of ApplicationFailure' ) ;
971
971
}
972
972
t . is ( err . cause . message , 'interrupted from signalWithStart' ) ;
0 commit comments