Writing a Test for `HttpError` Assertion in `effect-http`

Hi I'm trying to write a test which involves assertion on an HttpError from effect-http.

My test is pretty straightforward

it.effect('should return error', () =>
  Effect.gen(function* () {
    const body = {
      id: 'cq77vwelou',
      eventName: 'continue',
      interactionId: '18a833b0-32e8-4e81-aba4-85d5e6f62077',
      parameters: {
        eventType: 'submit',
        data: {
          actionKey: 'SIGNON',
          formData: {
            value: {
              pingprotectsdk: '',
            },
          },
        },
      },
    };
    const { handleCustomHtmlTemplate } = yield* CustomHtmlTemplate;
    const result = yield* handleCustomHtmlTemplate({ cookie: 'stepIndex=1' }, queryParams, body);
    expect(result).toEqual(HttpError.unauthorized('invalid protect node, did not pass validation'));
  }).pipe(Effect.provide(Layer.provideMerge(mockCustomHtmlTemplate, mockRequest))),
)


I see this in my console though.

Error: An error has occurred
 ❯ Function.unsafeFromUnknown ../../node_modules/effect-http-error/src/internal/http-error.ts:46:12
 ❯ Module.<anonymous> ../../node_modules/effect-http-error/src/internal/http-error.ts:94:17
 ❯ Object.InvalidProtectNode src/services/custom-html-template.service.ts:47:27
     45|               NoSuchElementException: () => HttpError.unauthorized('could not find the element'),
     46|               InvalidProtectNode: () =>
     47|                 HttpError.unauthorized('invalid protect node, did not pass validation'),
       |                           ^
     48|               InvalidUsernamePassword: () =>
     49|                 HttpError.unauthorized('invalid username or password, did not pass validation')


It looks like i'm hitting this path, as I expect.

But for some reason it just prints out the serialized error
Was this page helpful?