Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias not being resolved when mocking a module since 0.27.3 #2775

Closed
6 tasks done
kalvenschraut opened this issue Jan 30, 2023 · 3 comments · Fixed by #2777
Closed
6 tasks done

Alias not being resolved when mocking a module since 0.27.3 #2775

kalvenschraut opened this issue Jan 30, 2023 · 3 comments · Fixed by #2777

Comments

@kalvenschraut
Copy link
Contributor

kalvenschraut commented Jan 30, 2023

Describe the bug

image
For example I use @ to point to my src directory and instead I have to use ../src/ instead since my tests are in a test dir at the top level.

Reproduction

broken case on https://stackblitz.com/edit/vitest-dev-vitest-mmdlkp?file=package.json 0.27.3

working case on https://stackblitz.com/edit/vitest-dev-vitest-7vrs2x?file=package.json 0.27.2

Note same test case for both just changed version for your convenience. Its also still broken on the latest version at time of writing this (0.28.3)

System Info

repo on stackblitz

Used Package Manager

npm

Validations

@philipbushnell-valtech
Copy link

It might be bigger than just aliases. I have the following in my vitest.setup.ts and it's also stopped working from 0.27.3 onwards (up to 0.28.3, the latest at time of writing):

vi.mock('vue-i18n', () => ({
  useI18n: () => ({ t: (key: string) => key }),
}));

I had to downgrade to 0.27.2.

Interestingly, I also have this in my vitest.setup.ts and it works just fine:

vi.mock('nuxt/app', () => ({
  useRuntimeConfig: () => ({
    ...
    public: {
      ...
    },
  }),
}));

@sheremet-va
Copy link
Member

Probably because of this: #2687

We need to revert it

@jgoux
Copy link
Contributor

jgoux commented Feb 1, 2023

Hello 👋

After investigating my own issue: #2787 I realized this was caused by the same code!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants