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

vitest fails to recognize webpack module federation components because of which the tests fail #6466

Closed
6 tasks done
sumeetgodse opened this issue Sep 9, 2024 · 1 comment

Comments

@sumeetgodse
Copy link

Describe the bug

vitest fails to recognize webpack module federation components from remote applications because of which the tests fail

I am currently using vitest (0.33.0) in my application for testing the code. When I tried to upgrade to the latest version (2.0.5) , I encountered the below problem. I am not able to find a good way to fix this and proceed so creating this report.

image

Any help to resolve the issue appreciated. Thanks!

Reproduction

This is a very simple & minimal reproduction for the issue I am facing -

https://github.com/sumeetgodse/testing-microfes-1

Clone the repo

app1

  • cd app1
  • npm install
  • npm start
image

Tests for app1 (tests for apps that do not import any module federation components PASS)

  • npm test
image

container

  • cd container
  • npm install
  • npm start
image

Tests for container (FAILS)

image

Any help appreciated, Thanks!

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1265U
    Memory: 5.26 GB / 15.44 GB
  Binaries:
    Node: 18.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.3.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.10.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    vitest: ^2.0.5 => 2.0.5

Used Package Manager

npm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Sep 9, 2024

Vitest doesn't know what module federation and app1 is. To fix this, you can add aliases to your vitest.config, for example:

import { defineConfig } from 'vitest/config'
import { fileURLToPath } from 'node:url'

export default defineConfig({
  resolve: {
    alias: [
      { find: /^app1/, replacement: fileURLToPath(new URL('../app1/src/components', import.meta.url)) }
    ],
  },
})

@sheremet-va sheremet-va closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants