NuxtN
Nuxt11mo ago
13 replies
dmarr

Mocking auto-imported server utils in tests

I have a server util that uses a nuxt auto import. So there is no import { dbQuery } from './db' in my util that I want to test.
In my .test file, I thought I could do:
vi.mock('../../../server/utils/db', () => {
  return {
    dbQuery: async () => [

but the test run fails because dbQuery is not found.

I've tried using db ,dbQuery ,#imports in the mock path, but none work.
ReferenceError: dbQuery is not defined
Was this page helpful?