Meteor test: client and server run simultaneously


#1

I’m using latest meteor and practicalmeteor:mocha for full integration tests as described here: http://guide.meteor.com/testing.html#full-app-integration-test

I can’t find it in docs, but I’ve just found that the tests on client and server are run at the same time. This is a big issue because I write/read to the same collections both on client and server. Currently all my tests fail because of that, and I need to skip all server tests to focus on client and vice versa.
This is similar to here: https://github.com/meteor/meteor/issues/5784#issuecomment-194024881

Is it intended to run server and client tests in parallel?


#2

I think the integration tests are meant to be done from the UI perspective using Chimp with the database being set up with test data prior to execution.

If you want to do server side only test then I would do them as standard unit tests running on mocha and placed in the server/ folder


#3

I’ve done many Chimp tests and I want to avoid E2E testing, because 1. UI changes quite often, 2. UI testing is unstable. Actually I was waiting for 1.3 to be released because of the test support.

So now I’m stuck when trying to test route data availability just like in the example in guide. At the same time the server test is executed - where I test importing to collection from external datasource. Both tests read from the same collection and assert failure on wrong result.
It’s not really possible for me to use unit tests instead of integration tests, because 1. I want to test database save, 2. I haven’t yet migrated the code to ES6 Modules, so I won’t be able to import my code in the unit testing mode.


#4

The unit tests allow for database save actually. As long as it is server side only.


#5

I had to rename the title of this thread from full-app testing problem to whole meteor test command problem.
I’ve now tested unit testing run on client and server and it’s same issue here. Client test code breaches server test code and vice versa. I’m trying to understand what was the idea behind running server and client tests simultaneously. I’m also scared that community didn’t point this out - maybe people just monkey-test their client?
OK I understand, client side tests are meant to ensure correct interaction with UI only. But there are scenarios that can only be covered on client side - e.g. testing allow/deny permissions or routing.

As a workaround I define environment variables to switch between client/server tests on consecutive executions in CI. But this solution is horrible from engineering point of view.


#6

If this isn’t a bug, it’s a terrible design. It goes against the whole point of unit testing. Unit tests should be done in controlled environments.