-
Notifications
You must be signed in to change notification settings - Fork 665
Description
Subject of the issue
Hello all and thanks for the open source work you do 👋. I am currently developing an application using microfrontends with the framework single-spa. A general architecture overview looks somewhat like this:
- Main app (Major) is responsible for auth, loading dependencies, routing and the index.html layout
- Smaller apps (microapps) make up each route and are loaded inside a specific div
Now each one of those apps is a separate repository and a separate Vue application. Each one has their own set of tests and it only outputs a final javascript bundle that gets loaded by the Main app.
When developing tests for these smaller apps we make use of components from our component library and other components from the Major app.
We import them like so
import { ComponentA } from '@unbabel/major'; import { ComponentB } from '@unbabel/ui';
These components do not exist on the local app because they are avaliable in the Main app. @unbabel/major is also not an npm package (contrary to @unbabel/ui).
What does this mean?
Imagine you are testing a component from one of those microapps. You will not be able to mount your component without some of the child components being stubs because Vue Test Utils has no idea on where to get them. Using the above example, Vue Test Utils will not be able to mount ComponentA because for the microapp @unbabel/major does not exist.
So whenever you want to find this component in your tests you won't be able to use:
findComponent( ComponentA )
you also won't be able to use
findComponent ({ name: ComponentA_Name })
this leaves us with
findComponent ({ ref: ComponentA_Ref })
However this will mean some of the previous components that didn't need refs to be found now need them (previously we could use find with data-testid)
What should be the approach in this situations?
I am more than happy to jump on a call and talk about the issue more in depth 😁
Steps to reproduce
- Create a simple single-spa multi-application setup.
- Develop an example component on the Main application of the microfrontend repository you just created
- Try to test attributes being passed to that component in one of the children applications
Expected behaviour
Maybe there should be a different way to find components? Maybe not deprecating the querySelector syntax?
Actual behaviour
You will need to add refs to a lot of components to find them
Possible Solution
n/a