Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(workflow): Add integration tests for workflowInfo().lastfailure #1543

Merged
merged 4 commits into from
Oct 15, 2024
Merged
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
17 changes: 17 additions & 0 deletions packages/test/src/test-integration-workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,23 @@ test('Abandon activity cancel before started works', async (t) => {
t.pass();
});

export async function WorkflowWillFail(): Promise<string | undefined> {
if (workflow.workflowInfo().attempt > 1) {
return workflow.workflowInfo().lastFailure?.message;
}
throw ApplicationFailure.retryable('WorkflowWillFail', 'WorkflowWillFail');
}

test("WorkflowInfo().lastFailure contains last run's failure on Workflow Failure", async (t) => {
const { createWorker, startWorkflow } = helpers(t);
const worker = await createWorker();
const handle = await startWorkflow(WorkflowWillFail, { retry: { maximumAttempts: 2 } });
await worker.runUntil(async () => {
const lastFailure = await handle.result();
t.is(lastFailure, 'WorkflowWillFail');
});
});

export const interceptors: workflow.WorkflowInterceptorsFactory = () => {
const interceptorsFactoryFunc = module.exports[`${workflow.workflowInfo().workflowType}Interceptors`];
if (typeof interceptorsFactoryFunc === 'function') {
Expand Down
Loading