How to unit test server-only files in next js.

I am curretly trying to unit test server-only file using vitest and it is throwing error:-

FAIL  src/lib/session.test.ts [ src/lib/session.test.ts ]
Error: This module cannot be imported from a Client Component module. It should only be used from a Server Component.
 ❯ Object.<anonymous> node_modules/.pnpm/[email protected]/node_modules/server-only/index.js:1:7

i tried mocking it but its not working.Any help would be appreciated.