Meteor 1.6.1 - Practical Mocha invalid reporter "[object Object]"

After update to Meteor 1.6.1, when I want to test using:

meteor test --full-app --driver-package practicalmeteor:mocha

Error occur and show only blank page, not the usual html reporter page.

> meteor reset && meteor test --full-app --driver-package practicalmeteor:mocha --port 3220 --settings __tests__/settings.json

Project reset.                                
[[[[[ Tests ]]]]]                             

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:3220/
W20180131-18:13:07.799(7)? (STDERR) "[object Object]" reporter blew up with error:
W20180131-18:13:07.858(7)? (STDERR) AssertionError [ERR_ASSERTION]: path must be a string
W20180131-18:13:07.858(7)? (STDERR)     at Module.require (module.js:586:3)
W20180131-18:13:07.859(7)? (STDERR)     at require (internal/module.js:11:18)
W20180131-18:13:07.859(7)? (STDERR)     at Mocha.reporter (/home/andreas/.meteor/packages/practicalmeteor_mocha-core/.1.0.1.117ym50++os+web.browser+web.cordova/npm/node_modules/mocha/lib/mocha.js:167:21)
W20180131-18:13:07.859(7)? (STDERR)     at MochaRunner.coffee.js.MochaRunner.runServerTests (packages/practicalmeteor_mocha/meteor/src/lib/MochaRunner.coffee:72:19)
W20180131-18:13:07.859(7)? (STDERR)     at MochaRunner.runServerTests (packages/practicalmeteor_mocha/meteor/src/lib/MochaRunner.coffee:1:1)
W20180131-18:13:07.860(7)? (STDERR)     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1768:12)
W20180131-18:13:07.860(7)? (STDERR)     at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
W20180131-18:13:07.860(7)? (STDERR)     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
W20180131-18:13:07.860(7)? (STDERR)     at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
W20180131-18:13:07.860(7)? (STDERR)     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
W20180131-18:13:07.861(7)? (STDERR)     at Promise (packages/ddp-server/livedata_server.js:715:46)
W20180131-18:13:07.861(7)? (STDERR)     at new Promise (<anonymous>)
W20180131-18:13:07.869(7)? (STDERR)     at Session.method (packages/ddp-server/livedata_server.js:689:23)
W20180131-18:13:07.870(7)? (STDERR)     at packages/ddp-server/livedata_server.js:559:43
I20180131-18:13:07.870(7)? Exception while invoking method 'mocha/runServerTests' Error: invalid reporter "[object Object]"
I20180131-18:13:07.871(7)?     at Mocha.reporter (/home/andreas/.meteor/packages/practicalmeteor_mocha-core/.1.0.1.117ym50++os+web.browser+web.cordova/npm/node_modules/mocha/lib/mocha.js:180:13)
I20180131-18:13:07.871(7)?     at MochaRunner.coffee.js.MochaRunner.runServerTests (packages/practicalmeteor_mocha/meteor/src/lib/MochaRunner.coffee:72:19)
I20180131-18:13:07.871(7)?     at MochaRunner.runServerTests (packages/practicalmeteor_mocha/meteor/src/lib/MochaRunner.coffee:1:1)
I20180131-18:13:07.872(7)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1768:12)
I20180131-18:13:07.872(7)?     at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
I20180131-18:13:07.872(7)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
I20180131-18:13:07.873(7)?     at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
I20180131-18:13:07.873(7)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
I20180131-18:13:07.873(7)?     at Promise (packages/ddp-server/livedata_server.js:715:46)
I20180131-18:13:07.873(7)?     at new Promise (<anonymous>)
I20180131-18:13:07.873(7)?     at Session.method (packages/ddp-server/livedata_server.js:689:23)
I20180131-18:13:07.874(7)?     at packages/ddp-server/livedata_server.js:559:43

Anyone can help?
Thank you.

Check the release notes:

… One notable example is the practicalmeteor:mocha package. If you have been using this test-driver package, we strongly recommend switching to meteortesting:mocha instead…

1 Like

I will try to switch to meteortesting:mocha.
Thank you @robfallows.

1 Like

Nope. Still have error.

> meteor reset && meteor test --full-app --driver-package meteortesting:mocha --port 3220 --settings __tests__/settings.json

Project reset.                                
[[[[[ Tests ]]]]]                             

=> Started proxy.                             
=> Started MongoDB.                           
I20180131-19:17:21.619(7)?                    
I20180131-19:17:21.653(7)? --------------------------------
I20180131-19:17:21.653(7)? ----- RUNNING SERVER TESTS -----
I20180131-19:17:21.654(7)? --------------------------------
I20180131-19:17:21.654(7)? 
W20180131-19:17:21.658(7)? (STDERR) /home/andreas/.meteor/packages/meteor-tool/.1.6.1.1h008v2.r2k0j++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20180131-19:17:21.659(7)? (STDERR) 						throw(ex);
W20180131-19:17:21.659(7)? (STDERR) 						^
W20180131-19:17:21.660(7)? (STDERR) 
W20180131-19:17:21.660(7)? (STDERR) ReferenceError: document is not defined
W20180131-19:17:21.660(7)? (STDERR)     at fragment (/home/andreas/.meteor/packages/practicalmeteor_mocha-core/.1.0.1.117ym50++os+web.browser+web.cordova/npm/node_modules/mocha/lib/reporters/html.js:266:13)
W20180131-19:17:21.660(7)? (STDERR)     at new HTML (/home/andreas/.meteor/packages/practicalmeteor_mocha-core/.1.0.1.117ym50++os+web.browser+web.cordova/npm/node_modules/mocha/lib/reporters/html.js:53:14)
W20180131-19:17:21.661(7)? (STDERR)     at Mocha.run (/home/andreas/.meteor/packages/practicalmeteor_mocha-core/.1.0.1.117ym50++os+web.browser+web.cordova/npm/node_modules/mocha/lib/mocha.js:474:18)
W20180131-19:17:21.661(7)? (STDERR)     at serverTests (packages/meteortesting:mocha/server.js:98:17)
W20180131-19:17:21.661(7)? (STDERR)     at Object.start (packages/meteortesting:mocha/server.js:144:5)
W20180131-19:17:21.661(7)? (STDERR)     at packages/meteor.js:1107:27
W20180131-19:17:21.662(7)? (STDERR)     at Function.time (/tmp/meteor-test-run1yzf5sz.w3z1/.meteor/local/build/programs/server/profile.js:309:28)
W20180131-19:17:21.662(7)? (STDERR)     at /tmp/meteor-test-run1yzf5sz.w3z1/.meteor/local/build/programs/server/boot.js:427:13
W20180131-19:17:21.662(7)? (STDERR)     at /tmp/meteor-test-run1yzf5sz.w3z1/.meteor/local/build/programs/server/boot.js:472:5
W20180131-19:17:21.662(7)? (STDERR)     at Function.run (/tmp/meteor-test-run1yzf5sz.w3z1/.meteor/local/build/programs/server/profile.js:510:12)
W20180131-19:17:21.663(7)? (STDERR)     at /tmp/meteor-test-run1yzf5sz.w3z1/.meteor/local/build/programs/server/boot.js:470:11
=> Exited with code: 1

Package meteortesting:mocha still requires practicalmeteor:mocha-core.

Any other test solution? @robfallows
Thank you.

That’s a different error.

I think document in server code looks suspicious - is it possible that’s in your test code and is being run on the server, instead of the client?

Yes, the error is different, because I use meteortesting:mocha as driver package now.

Do I need to create another topic?

My main purpose here is ability to test.
I can not upgrade to 1.6.1 unless I am able to run the test (I am thinking about rollback now).

I try to create server only app.
But the document there was called inside mocha library.
When I was using practicalmeteor:mocha, the default report shows in a web page.

I don’t think I can offer any more help. We use our own test runner.

Is it working? :laughing:
I will try it in the morning.
Thank you.

I can not find centiq:testing in atmosphere.
I take a look at the code and centiq:testing requires practicalmeteor:mocha-core too.

Test driver packages are breaking, yet in the documentation to testing meteor package, Meteor still refers to use practicalmeteor:mocha.
https://guide.meteor.com/writing-atmosphere-packages.html#testing

The current situation is questionable.
When meteor update to 1.6.1, how other packages (contributors) able to test?

practicalmeteor:mocha points to coffeescript 1 which is not supported when running on Meteor 1.6.1 anymore. Which has also been mentioned in the blog article.

However, switching to meteortesting:mocha is not trivial, since it’s reporters behave differently and you have to change your setup.

I already opened a PR on their repo: https://github.com/practicalmeteor/meteor-mocha/issues/99

But it seems that this repo is not really maintained anymore :frowning:

I am waiting a little bit more in the hope that they will make a compatibility build or something and if not, switch also to meteortesting:mocha but currently there is no time for me to hack around for two days just in order to get my tests running just because of a version update.

Just to clarify that practicalmeteor:mocha-core does not depend on coffeescript - it’s just plain JavaScript which wraps npm’s mocha package in Fibers.

It is the case that the version of mocha it’s using is old (2.4.5) vs the current version (5.0.0). As far as I can see, while there are some worthwhile improvements in mocha, I don’t think that there’s anything in practicalmeteor:mocha-core which should break in Meteor 1.6.1.

2 Likes

Thanks @robfallows this gives me courage to find hack around it… :nerd_face:

1 Like

Good call!

Now available.

1 Like

Thank you!! @robfallows
Package centiq:testing works!

But I rolled it back to 1.6.0.1 yesterday.
I agree with @jkuester.

Thanks @robfallows for the clarification here. Then it is even worse, because the package maintainer wouldn’t have to do a lot of work to upgrade… :frowning:

Right so moving to meteortesting:mocha what should the following line in your tests be replaced with?

import { chai, expect } from 'meteor/practicalmeteor:chai';

No idea. As I said above, we use our own package.

Replace it with normal chai from npm.

meteor npm i -D chai

Then

import { expect } from ‘chai’;

or

const { expect } = require(‘chai’); // I use this one for latest test.

Hope this helps.

@diaconutheodor published a fork on atmosphere for practical mocha that is working with Meteor 1.6.1 (thanks!) and opened an issue at practical mocha repo. The guide is still recommending practical mocha and I think it’s great for testing especially with the browser report.

Hopefully practical mocha (or fork) gets maintained because it’s great to work with and switching to meteortesting:mocha as per the meteor 1.6.1 recommendation doesn’t seem to be a straight forward or desirable solution.

2 Likes

https://github.com/cult-of-coders/meteor-mocha – I just love practicalmeteor:mocha it’s so simple, so elegant to test and see results. I think it’s perfect the way it is I’ll make sure it’ll work on future Meteor releases

4 Likes