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

Help needed: can't integrate tests, added test file to imports directory but not eagerly loading #78

Closed arifmahmudrana closed 5 years ago

arifmahmudrana commented 6 years ago

I have a very basic meteor app. I have added your package now I added a test file in imports/startup/simple-schema.tests.js

describe('Todos_item', function () {
  console.log('Todo');
});

I was running npm run test-app so it should be logged in console but that file actually doesn't run. But when I added this snippet to my tests/main.js Todo is logged in console. So am I missing something.

Meteor version 1.7.0.5.

My directory tree directory-tree & package.json

{
  "name": "meteor-bootstrap",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "test": "meteor test --once --driver-package meteortesting:mocha",
    "test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha",
    "visualize": "meteor --production --extra-packages bundle-visualizer"
  },
  "dependencies": {
    "@babel/runtime": "7.0.0-beta.55",
    "meteor-node-stubs": "^0.4.1",
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-router-dom": "^4.3.1",
    "simpl-schema": "^1.5.3"
  },
  "meteor": {
    "mainModule": {
      "client": "client/main.js",
      "server": "server/main.js"
    },
    "testModule": "tests/main.js"
  },
  "engines": {
    "node": "8.11.4"
  }
}
SimonSimCity commented 6 years ago

I haven't found it any other place but in the history: https://github.com/meteor/meteor/blob/devel/History.md

When specified, these entry points override Meteor's default module loading semantics, rendering imports directories unnecessary. If mainModule is left unspecified for either client or server, the default rules will apply for that architecture, as before. To disable eager loading of modules on a given architecture, simply provide a mainModule value of false:

This yields both for mainModule but also for testModule as far as I know - but I haven't really tested it. At least this makes much more sense when reading the following part:

The same test module will be loaded whether or not you use the --full-app option. Any tests that need to detect --full-app should check Meteor.isAppTest. The module(s) specified by meteor.testModule can import other test modules at runtime, so you can still distribute test files across your codebase; just make sure you import the ones you want to run.

This last sentence should make it clear. But it's not that clear anyways, I think ... and it's missing a good part in the official docs, or at least I haven't found it.

Please add if anyone has additional resources that could be of value.

SimonSimCity commented 6 years ago

@arifmahmudrana was what I wrote helpful to you? Is the issue still present? If I do not hear back from you by the end of this year, I'll close this issue as reproducible and missing feedback.

derwaldgeist commented 4 years ago

Same problem here. My tests are just not being executed.

I also had the meteor section in my package.json, but even when I delete it, the same problem occurs.

How can I activate eager-loading of test files in the imports folder, as described in the Meteor guide?!

SimonSimCity commented 4 years ago

As said, this is not the responsibility of this package but of the framework itself.

If you need some help, please ask your question on the Meteor Community Slack channel: https://meteor-community.slack.com/