@@ -561,13 +561,22 @@ describe('e2e', () => {
561561 const run = await triggerWorkflow ( 'crossFileErrorWorkflow' , [ ] ) ;
562562 const returnValue = await getWorkflowReturnValue ( run . runId ) ;
563563
564- // The workflow should fail with the error from the helper module
565- expect ( returnValue ) . toHaveProperty ( 'error' ) ;
566- expect ( returnValue . error ) . toContain ( 'Error from imported helper module' ) ;
564+ // The workflow should fail with error response containing both top-level and cause
565+ expect ( returnValue ) . toHaveProperty ( 'name' ) ;
566+ expect ( returnValue . name ) . toBe ( 'WorkflowRunFailedError' ) ;
567+ expect ( returnValue ) . toHaveProperty ( 'message' ) ;
568+
569+ // Verify the cause property contains the structured error
570+ expect ( returnValue ) . toHaveProperty ( 'cause' ) ;
571+ expect ( returnValue . cause ) . toBeTypeOf ( 'object' ) ;
572+ expect ( returnValue . cause ) . toHaveProperty ( 'message' ) ;
573+ expect ( returnValue . cause . message ) . toContain (
574+ 'Error from imported helper module'
575+ ) ;
567576
568- // Verify the stack trace is present and shows correct file paths
569- expect ( returnValue ) . toHaveProperty ( 'stack' ) ;
570- expect ( typeof returnValue . stack ) . toBe ( 'string' ) ;
577+ // Verify the stack trace is present in the cause
578+ expect ( returnValue . cause ) . toHaveProperty ( 'stack' ) ;
579+ expect ( typeof returnValue . cause . stack ) . toBe ( 'string' ) ;
571580
572581 // Known issue: SvelteKit dev mode has incorrect source map mappings for bundled imports.
573582 // esbuild with bundle:true inlines helpers.ts but source maps incorrectly map to 99_e2e.ts
@@ -578,24 +587,27 @@ describe('e2e', () => {
578587
579588 if ( ! isSvelteKitDevMode ) {
580589 // Stack trace should include frames from the helper module (helpers.ts)
581- expect ( returnValue . stack ) . toContain ( 'helpers.ts' ) ;
590+ expect ( returnValue . cause . stack ) . toContain ( 'helpers.ts' ) ;
582591 }
583592
584593 // These checks should work in all modes
585- expect ( returnValue . stack ) . toContain ( 'throwError' ) ;
586- expect ( returnValue . stack ) . toContain ( 'callThrower' ) ;
594+ expect ( returnValue . cause . stack ) . toContain ( 'throwError' ) ;
595+ expect ( returnValue . cause . stack ) . toContain ( 'callThrower' ) ;
587596
588597 // Stack trace should include frames from the workflow file (99_e2e.ts)
589- expect ( returnValue . stack ) . toContain ( '99_e2e.ts' ) ;
590- expect ( returnValue . stack ) . toContain ( 'crossFileErrorWorkflow' ) ;
598+ expect ( returnValue . cause . stack ) . toContain ( '99_e2e.ts' ) ;
599+ expect ( returnValue . cause . stack ) . toContain ( 'crossFileErrorWorkflow' ) ;
591600
592601 // Stack trace should NOT contain 'evalmachine' anywhere
593- expect ( returnValue . stack ) . not . toContain ( 'evalmachine' ) ;
602+ expect ( returnValue . cause . stack ) . not . toContain ( 'evalmachine' ) ;
594603
595- // Verify the run failed
604+ // Verify the run failed with structured error
596605 const { json : runData } = await cliInspectJson ( `runs ${ run . runId } ` ) ;
597606 expect ( runData . status ) . toBe ( 'failed' ) ;
598- expect ( runData . error ) . toContain ( 'Error from imported helper module' ) ;
607+ expect ( runData . error ) . toBeTypeOf ( 'object' ) ;
608+ expect ( runData . error . message ) . toContain (
609+ 'Error from imported helper module'
610+ ) ;
599611 }
600612 ) ;
601613} ) ;
0 commit comments