Skip to content

How to mock useAuth in Vitest ?  #596

Open
@ErinTran15

Description

@ErinTran15

Environment

No response

Reproduction

No response

Describe the bug

I've been trying to do vi.mock and unplugin-auto-import to mock it but none of them works
when I config it in unplugin-auto-import in vitest.config.ts like this

 imports: [
      'vue',
      'vue-router',
      {
        '@sidebase/nuxt-auth: [
          "useAuth"
        ],
      },
    ],

surely it won't work because its the wrong path
but when I import it with the correct path like in auto import path it will give me error:

 imports: [
      'vue',
      'vue-router',
      {
        '@sidebase/nuxt-auth/dist/runtime/composables/authjs/useAuth': [
          "useAuth"
        ],
      },
    ],

Missing "./dist/runtime/composables/authjs/useAuth" specifier in "@sidebase/nuxt-auth" package

pls is there any other ways I could mock it ? Really appreciate if you guys can help me

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions