meteor-mocha
meteor-mocha copied to clipboard
meteor test-packages does not find any tests, but the files are executed
This is a strange one. Prepare!
METEOR_PACKAGE_DIRS="../../grapher-boilerplate/packages" TEST_BROWSER_DRIVER=chrome meteor test-packages --once --driver-package meteortesting:mocha ../../grapher-boilerplate/packages/grapher
Output:
I20181025-09:19:31.701(3)? [testing] Loading test fixtures ...
I20181025-09:19:33.653(3)? [ok] fixtures have been loaded.
I20181025-09:19:33.862(3)? testing server-side
I20181025-09:19:33.995(3)?
I20181025-09:19:33.996(3)? --------------------------------
I20181025-09:19:33.996(3)? ----- RUNNING SERVER TESTS -----
I20181025-09:19:33.996(3)? --------------------------------
I20181025-09:19:33.997(3)?
I20181025-09:19:33.997(3)?
I20181025-09:19:33.997(3)?
I20181025-09:19:33.997(3)? 0 passing (0ms)
I20181025-09:19:33.997(3)?
I20181025-09:19:33.998(3)?
I20181025-09:19:33.998(3)? --------------------------------
I20181025-09:19:33.998(3)? ----- RUNNING CLIENT TESTS -----
I20181025-09:19:33.998(3)? --------------------------------
=> Started your app.
=> App running at: http://localhost:3000/
I20181025-09:19:35.304(3)?
I20181025-09:19:35.304(3)?
I20181025-09:19:35.305(3)? 0 passing (2ms)
I20181025-09:19:35.305(3)?
I20181025-09:19:35.375(3)? All tests finished!
I20181025-09:19:35.375(3)?
I20181025-09:19:35.376(3)? --------------------------------
I20181025-09:19:35.376(3)? SERVER FAILURES: 0
I20181025-09:19:35.377(3)? CLIENT FAILURES: 0
I20181025-09:19:35.377(3)? --------------------------------
No tests are found. But they do exist.
If you want to reproduce you can clone grapher, and modify the paths: https://github.com/cult-of-coders/grapher
I'm working on it right now trying to figure it out. Meanwhile I leave it here.
I do not think this package is meant to be used with test-packages?
@mitar it worked previously
Can you please set up a list of steps to reproduce this? I wasn't able to ...
When downloading the linked repo and just calling meteor test-packages --driver-package meteortesting:mocha
, I got the following error:
/Users/simon/.meteor/packages/meteor-tool/.1.6.0.1wb5jju.3tivf++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:218
throw error;
^
Error: Error: Could not install npm dependencies for test-packages: Command failed: /Users/simon/.meteor/packages/meteor-tool/.1.6.0.1wb5jju.3tivf++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/bin/npm install
npm ERR! Cannot read property 'match' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/simon/.npm/_logs/2018-11-20T08_01_06_422Z-debug.log
npm ERR! Cannot read property 'match' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/simon/.npm/_logs/2018-11-20T08_01_06_422Z-debug.log
at Object.error (/tools/utils/buildmessage.js:430:11)
at /tools/cli/default-npm-deps.js:32:20
at /tools/utils/buildmessage.js:334:18
at exports.EnvironmentVariable.withValue (/tools/utils/fiber-helpers.js:89:14)
at /tools/utils/buildmessage.js:333:36
at exports.EnvironmentVariable.withValue (/tools/utils/fiber-helpers.js:89:14)
at Object.enterJob (/tools/utils/buildmessage.js:324:26)
at Object.install (/tools/cli/default-npm-deps.js:27:27)
at doTestCommand (/tools/cli/commands.js:1678:40)
at Command.func (/tools/cli/commands.js:1585:10)
at /tools/cli/main.js:1522:15
EDIT: Who thought this error was raised because I had not yet agreed to the Xcode license? 🤦♂️
And yes, now I am witness to the exact same phenomena.
One thing that I wonder about here is, that the test-files are not imported or run at all - at least this is what I can confirm by adding a console.log()
statement into one of these files. They exist, yes, but they aren't loaded. I'll dive deeper ...
I was able to get it running by the following steps:
- Clone https://github.com/cult-of-coders/grapher into a folder of choice
- Open the folder in the command line
- Run
meteor npm i --save-dev puppeteer@^1.2.0 chai@^4.1.2
- Run
TEST_BROWSER_DRIVER=puppeteer meteor test-packages ./ --driver-package meteortesting:mocha --raw-logs --once
Earlier I was able to reproduce your error, but not anymore. I had your repo checked out with the problem and created a plain new package which worked. From there on I started moving all your files over to the other project, where it (after all files were moved) still worked. After that, I removed all I had on testing stuff, cloned your project and did the steps written above, which worked for me.
Setting METEOR_PACKAGE_DIRS
should not have any affect since it's only used in development
or production
but the docs don't say anything about testing: https://docs.meteor.com/environment-variables.html#METEOR-PACKAGE-DIRS
But loading the test-files generally is the job of Meteor, not of this plugin.
@theodorDiaconu @SimonSimCity I got the same issue with my repo. Got it finally running by using
api.mainModule('myPackage.tests.js');
and imported all the tests files relative from this file (no api.addFiles
required then).
Please try, if it solves your problem. If so, I will create a PR and add this to the README
Edit: with this you also don't need to define a browser driver, unless you want to execute the tests cli-only. I use this for example in this package successfully: https://github.com/cquencial/meteor-bpmn-engine
I am trying to run test cases with meteor with this command
TEST_WATCH=1 meteor test --driver-package meteortesting:mocha --port 3100
It's throwing error : Error: ENOENT: no such file or directory, open '/private/var/folders/q4/rl0c5md979d6xz32795bxfrm0000gq/T/meteor-test-run1hflvik.7mvil/packages/implementation/settings.json'
I don't know what is the issue. I am not to much familiar with meteor.
@harmansingh2908 please do not just add it to every issue still open but add it as a separate one.
A follow-up on this issue - I have reproduced this issue and it turns out that when I run the package tests as in the constellation in grapher (using a host project with npm installed headless browser) then I will not get any error output, in case the package contains immediately added files (using api.addFiles
) that throw a ReferenceError when trying to access a non-defined global.
The error is then not reported (it would show up in the browser console, if tests are running in a browser) and no tests from the suite are executed then.
OK, I just got hit with this, too. Is there a known solution to this?
So this is the package I am testing on: https://github.com/peerlibrary/meteor-reactive-mongo
Tests work for all standard drivers (test-in-browser
, test-in-console
, test-server-tests-in-console-once
) but not for this package. I am simply trying:
meteor test-packages ./ --driver-package meteortesting:mocha
From the clone of the repository.
My current workaround is not to use this package, but test-in-console
using this run script and this runner.