After some fiddling about it became apparent I had some fundamental misunderstanding on how the testing environment works. My confusion was partly reinforced by the inability to import
user-event v14-beta on the server while v13 can be imported just fine.
What I get from my attempts so far is:
- You can go very far by writing
--full-app tests without the need of external libraries. For instance there is no real need for me to use
@testing-library/react, the entire app can be spawned for tests without that. Though
@testing-library/user-event is useful to simulate real user interaction with the app.
- Although you write tests under
Meteor.isServer/isClient conditionals, hoisted import statement get executed in both environments if your tests are isomorphic. If those import statements break when for instance
global.window does not exist, it will break in the server environment.
- In normal mode (without
--full-app) NOTHING will be setup aside from the MongoDB process and connection. You get exactly what you import. However, tests are not isolated so your stuff could be working only because some other test file imports modules that cause side-effects you rely on.
- There is no supported way to run isolated tests in parallel in a real environment.
- Even if you configure
mainModule the testing file eager loading feature will fail to load files having a
client ancestor on their path in server mode and vice versa (which kind of makes sense, would probably work by setting
testModule but then you lose eager loading).