Integration testing with test client and HTTP only cookies

Hello,

I have an API with HTTP only cookies built with Hono (Behind Next.js https://hono.dev/docs/getting-started/vercel). I tried to do some integration testing with Hono test client and vitest. I ran into a big issue that is my HTTP only cookies aren't send back to the server. It's normal since HTTP only behavior is handle by the browser and not Node or bun. So I was wondering what tooling or how could i do this integration testing. I want to run it in my CI CD.

Any idea or recommendation is welcome ^^

import { config } from 'dotenv';
import { testClient } from 'hono/testing';
import { describe, expect, test } from 'vitest';

import app, { AppRoutes } from './app/api/[[...route]]/route';

describe('demo', () => {
  config();
  test('should work', async () => {
    const client = testClient<AppRoutes>(app);
    const res = await client.api.auth.login.$post(
      {
        json: {
          email: 'test69999dqsdqs@gmail.com',
          password: '#Password123',
        },
      },
      {
        init: {
          credentials: 'include',
        },
      }
    );
    console.log(await res.json());
    const res2 = await client.api.auth.me.$get(undefined, {
      init: {
        credentials: 'include',
      },
    });
    //Work !
    expect(res.status).toBe(201);
    // 401 No cookies has been send
    expect(res2.status).toBe(200);

  });
});


And with a console log in my middleware i seed that my cookie is not being send
Was this page helpful?