test-utils icon indicating copy to clipboard operation
test-utils copied to clipboard

alias in test files while using workspace not working

Open ThiloHettmer opened this issue 1 year ago • 1 comments

Environment

os: Ubuntu 22.04 node: 21.0.0 nuxt: 3.9.3 @nuxt/test-utils: 2.4.3 vitest: 1.0.4 pnpm: 8.3.1

Reproduction

https://github.com/ThiloHettmer/test-utils-alias-issue/tree/main

Describe the bug

Hi all,

we use a monorepo with multiple layers and apps. The aliases are declared in root via an alias.ts file. They work in our application but not in test files. I've tried alot of things to resolve these aliases but could not get it to work. Note: we want to start the vitest from the root folder and got a vitest.workspace.ts file.

Perhaps I'm just missing something.

Thanks, and gd

Additional context

No response

Logs

No response

ThiloHettmer avatar Jan 18 '24 12:01 ThiloHettmer

Hello,

You can resolve it by using extends property instead of plain string.

export default defineWorkspace([
  {
    extends: './path/to/app/vitest.config.js'
  }
])

but unfortunately, a new error occurs: ref is not defined (If you are using vue ref for example). This is related to nuxt auto-imports feature. I don't know how to solve it at the moment.

joris-fonck-loreal avatar Mar 12 '24 10:03 joris-fonck-loreal