Providing a stack trace for defects in an Effect can be a bit tricky, but you can achieve this by...

Hi! Could you help me to figure out how to correctly provide stack trace for Defects?

I have such a function that I use in testing:
export const ELEMENT_SHOULD_HAVE_TEXT = ({
  elementId,
  text,
}: {
  elementId: string;
  text: string;
}) =>
  Effect.tryPromise(async () => {
    const element = await screen.findByTestId(elementId);
    expect(element.textContent).toBe(text);
  }).pipe(
    Effect.catchTag("UnknownException", (err) =>
      Effect.die(new Error(`Could not find element with id ${elementId}`, err)),
    ),
    Effect.annotateLogs({
      elementId,
      text,
    }),
  );


how do I propagate stack trace to show where the effect produced by the function was yielded?
Was this page helpful?