entropyE
Convex Communityβ€’2y agoβ€’
27 replies
entropy

Failed to load url with convex-test

Hello, I'm trying to setup vitest and convex test but everytime I write a query or mutation I get a failed to load url error.

import { convexTest } from 'convex-test'
import { expect, test } from 'vitest'
import { api } from '../../_generated/api'
import schema from '../../schema'

test('creating a user', async () => {
    const t = convexTest(schema)
const mockUser = {
        clerkId: 'user_2fyL',
        username: 'cool username',
        tag: 'coolusername',
        updatedAt: new Date().getTime(),
        accountStanding: 'good'
    } satisfies WithoutSystemFields<Doc<'users'>>

    await t.mutation(api.functions.user.createUser, mockUser)

    const user = await t.run(async ctx => {
        return await ctx.db
            .query('users')
            .withIndex('by_clerkId', q => q.eq('clerkId', mockUser.clerkId))
            .first()
    })

    expect(user).toMatchObject(mockUser)
})
CleanShot_2024-05-09_at_11.56.432x.png
Was this page helpful?