Meteor-Community-Packages / meteor-mocha

A Mocha test driver package for Meteor 1.3+. This package reports server AND client test results in the server console and can be used for running tests on a CI server or locally.
https://packosphere.com/meteortesting/mocha
MIT License
67 stars 40 forks source link

Eager loading of tests does not work as described in the Meteor guide #99

Closed derwaldgeist closed 4 years ago

derwaldgeist commented 4 years ago

I am on a Meteor 1.8 app and tried to add mocha tests to it. My strategy would be based on eager loading, i.e. I want to place tests inside the imports folder, alongside the respective tested code, and I would love to have these tests run automatically, without having to reference them in a master spec file.

However, eager loading does not work as described in the Meteor guide. Even if I add the .spec.js extension to a test file, it won't be executed.

I found this similar issue #78 and noticed that I also had specified the mainModule and testModule values in package.json like this:

  "meteor": {
    "mainModule": {
      "client": "client/main.js",
      "server": "server/main.js"
    },
    "testModule": "tests/main.js"
  },

So I first tried to remove the testModule entry, but this did not work either. Then I removed the whole meteor section, but it still does not work. How is it actually possible to use eager loading for test files?

(If I specify testModule and manually reference a spec from tests/main.js, it works, but this would be pretty cumbersome.)

SimonSimCity commented 4 years ago

Loading of files (if eager or not) is part of the Meteor framework, not of this package. This yields for testing files as well as for files which are part of your application.

I don't want to shut you off here, but this problem is nothing which could be solved as part of this package.

I can have a look at your project if you're willing to upload a project to GitHub which describes the problem in a minimal configuration - but only if you're then willing to update the documentation of either this package or the Meteor Guide. Mainly because they (to me) are quite clear - but it's always harder to explain something if you (as the writer) have the full picture and some concepts, which others aren't familiar with, are obvious to you.

derwaldgeist commented 4 years ago

Ok, thanks for the feedback. I also assume it's a problem in Meteor itself, or the Meteor guide is just incorrect.