In memory tests with libsql?

Do you guys know if there's a way to get this working with libsql?

I'm using turso, and was hoping to get the DB working in memory for local tests.

I have this
import { describe, it, expect, beforeAll } from 'vitest';

import { db } from '$lib/server/db';
import * as userService from '$lib/server/users/service';
import { migrate } from 'drizzle-orm/libsql/migrator';
import { userTable } from '$lib/server/users/schema';

describe('userService test', () => {
    beforeAll(async () => {
        await migrate(db, { migrationsFolder: 'drizzle' });
    });

    it('allUsers', async () => {
        await userService.allUsers();
    });

    it('deleteUser', async () => {
        await userService.deleteUser('123');
    });

    it('addUser', async () => {
        await userService.addUser({ name: 'test', email: 'some@email.com' });
    });
});

I'm just setting the DATABASE_URL in env and passing that through.

I'm basically doing the same thing as mentioned here JS API for generating CREATE TABLE sql? however I'm using libsql
Was this page helpful?