Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions sdks/typescript/src/util/workflow-run-ref.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
RunListenerClient,
StepRunEvent,
} from '@hatchet/clients/listeners/run-listener/child-listener-client';
import { WorkflowRunEventType } from '../protoc/dispatcher';
import WorkflowRunRef from './workflow-run-ref';

describe('WorkflowRunRef', () => {
it('rejects failed runs with an Error containing only failed step messages', async () => {
const finishedEvent = {
eventType: WorkflowRunEventType.WORKFLOW_RUN_EVENT_TYPE_FINISHED,
results: [
{ taskName: 'successful-step', error: undefined, output: '{}' },
{ taskName: 'failed-step', error: 'step failed', output: '{}' },
],
} as unknown as StepRunEvent;
const client = {
get: jest.fn().mockResolvedValue({
stream: async function* () {
yield finishedEvent;
},
}),
} as unknown as RunListenerClient;
const workflowRun = new WorkflowRunRef('workflow-run-id', client);

expect.assertions(2);

try {
await workflowRun.result();
} catch (error) {
expect(error).toBeInstanceOf(Error);
expect((error as Error).message).toBe('step failed');
}
});
});
2 changes: 1 addition & 1 deletion sdks/typescript/src/util/workflow-run-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default class WorkflowRunRef<T> {
.filter((r) => r.error !== undefined && r.error !== '')
.map((r) => r.error);

reject(errors);
reject(new Error(errors.join('; ')));
return;
}

Expand Down