manfredsteyer / module-federation-plugin-example

258 stars 177 forks source link

ng test error: flights.module.ts is missing from the TypeScript compilation #4

Open careywalker opened 3 years ago

careywalker commented 3 years ago

Hi, thanks for providing this sample.

When I run ng test, I get the following error:

PS C:\Code\Repos\Git\module-federation-plugin-example-starter> ng test --browsers ChromeHeadless

I haven't managed to fix the issue so just checking to see if you had any ideas.

Santiago-Moreno commented 3 years ago

I noticed this issue as well and managed to fix it by including all typescript files (not just spec and d.ts) in every tsconfig. This is how the updated include in every tsconfig looks like:

"include": [
    "src/**/*.spec.ts",
    "src/**/*.d.ts",
    "src/**/*.ts"
  ]

After updating the tsconfigs it compiles fine, though a new error will be thrown once a browser instance gets started:
Uncaught Error: Shared module is not available for eager consumption This is an issue with the way microfrontends get loaded asynchronously (see this link and this one for more information). This issue can be fixed by moving the code from test.ts into a new file bootstrap-test.ts. test.ts then just has the following line of code: import('./bootstrap-test') This also has to be done for every test.ts file.

Now everything works without errors but now I'm facing the issue that no spec files are found. I always get this warning from Karma: Incomplete: No specs found, , randomized with seed. Even though I have created several specs. Does anybody know what might be the issue here ?