Skip to content
This repository has been archived by the owner on Dec 27, 2018. It is now read-only.

Pending tests on server don't display in reporter #42

Closed
evelant opened this issue May 16, 2016 · 34 comments
Closed

Pending tests on server don't display in reporter #42

evelant opened this issue May 16, 2016 · 34 comments

Comments

@evelant
Copy link

evelant commented May 16, 2016

Run the following test

describe('test', function() {
    // pending test below
    it('will only show up on client');
    it.skip('will also only show up on client',function(){});
    it('will show up on both client and server', function(){});
});

And the output will be:

capture

@evelant
Copy link
Author

evelant commented May 17, 2016

Probably related, lots of this showing up in my console when I run my tests

W20160517-14:11:46.738(-4)? (STDERR) MeteorPublishReporter.added: Can't send report data to client.
W20160517-14:11:46.738(-4)? (STDERR) MeteorPublishReporter.added: Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20160517-14:11:46.739(-4)? (STDERR) MeteorPublishReporter.added: Document: { _id: '23',
W20160517-14:11:46.739(-4)? (STDERR)   event: 'suite end',
W20160517-14:11:46.739(-4)? (STDERR)   data: 
W20160517-14:11:46.739(-4)? (STDERR)    { title: 'task model',
W20160517-14:11:46.739(-4)? (STDERR)      root: false,
W20160517-14:11:46.739(-4)? (STDERR)      pending: false,
W20160517-14:11:46.740(-4)? (STDERR)      _fullTitle: 'task model',
W20160517-14:11:46.740(-4)? (STDERR)      isServer: true } }

this is on Meteor Meteor 1.3.2.4

@jsep
Copy link

jsep commented May 17, 2016

Hello @fignuts thank you for reporting this issue.

The package it's working as expected for me, so I couldn't reproduce this issue.

According to the error shown by MeteorPublishReporter(package's class) in 'task model' suite you are running some code that needs to be wrapped under a Fiber. You can use Meteor.bindEnvironment(func, onExeception, this) to run code within a Fiber.

If you want to doble-check that it's a package error, you can use Todos example project to recreate the issue.

I hope this help. Let me know any progress.

@evelant
Copy link
Author

evelant commented May 17, 2016

I have only one .test.js file in my project with the following contents. The file imports nothing and is the only test file in my project.

describe('test', function() {
    // pending test below
    it('will only show up on client');
    it.skip('will also only show up on client',function(){});
    it('will show up on both client and server', function(){});
});

This is the console output I get:

https://gist.github.com/fignuts/40163fab06d6405ea6c521519b78cbd4

The tests run fine if I clone the Todos example project. I am not really sure how to proceed debugging this. There seems to be something in my project that conflicts with meteor-mocha but I am not sure how to find it.

@jsep
Copy link

jsep commented May 17, 2016

Thanks @fignuts It's hard find this way.

Are you using the latest package version (2.4.5_2)?

@evelant
Copy link
Author

evelant commented May 17, 2016

Yes I am using the latest version

@pcorey
Copy link

pcorey commented Jun 6, 2016

I've been having this same issue. As far as I know, none of my application code is running outside of a Fiber, and all of my test code is fairly standard. While my tests and web reporter are running just fine, these STDERR logs are fairly annoying.

I'd love to figure out what's going on here.

@jsep
Copy link

jsep commented Jun 6, 2016

@fignuts @pcorey Can you make a repo that replicate this issue?, It's difficult to know what is problem.

@rbabayoff
Copy link
Member

@tmeasday, any clues?

@rbabayoff
Copy link
Member

@fignuts and @pcorey, what OS are you own and which version of meteor?

@pcorey
Copy link

pcorey commented Jun 7, 2016

OSX El Capitan.
Meteor 1.3.2.4.

I tried to build a reproduction from scratch, but couldn't recreate the issue. I'll try to strip down my current project to a minimal reproduction.

@tmeasday
Copy link
Collaborator

tmeasday commented Jun 8, 2016

What is the underlying mocha wrapping library you are using these days?

@pcorey
Copy link

pcorey commented Jun 8, 2016

It looks like the culprit here is the peerlibrary:reactive-publish package. Removing that from my project fixes the STDERR output in test mode.

@fignuts - Are you using reactive-publish?

@evelant
Copy link
Author

evelant commented Jun 8, 2016

Yes, I am using that package.

@rbabayoff
Copy link
Member

So it seems it's a reactive-publish bug. @pcorey and @fignuts do you get this stderr outputs in your apps as well, i.e. with meteor run, not meteor test?

@sprintup
Copy link

sprintup commented Jun 8, 2016

I'm a noob, but I found this http://stackoverflow.com/questions/36593111/meteor-1-3-server-testing and my reporter is not working at all. I can't tell if this is related, sorry if it's not.

OSX El Capitan 10.11.3 | Meteor 1.3.2.4

Tried:
avital:mocha@2.1.0_10 (https://themeteorchef.com/blog/meteor-1-3-from-a-20-000-foot-view/) and practicalmeteor:mocha@2.4.6-rc.2 (https://forums.meteor.com/t/meteor-test-not-running-some-tests-and-not-throwing-errors/21232/3)

-Unit test was running with phantomjs, but not in the mocha test reporter.

@pcorey
Copy link

pcorey commented Jun 8, 2016

So it seems it's a reactive-publish bug.

@rbabayoff I don't know if I'd be so quick to say it's a reactive-publish bug. My application works fine with peerlibrary:reactive-publish in normal meteor mode and has since 1.2.

@mitar - Do you have any insights as to what might be causing this?

@mitar
Copy link

mitar commented Jun 8, 2016

No idea. I am not using mocha. But if mocha publish endpoints do not use autorun, then existence of reactive-publish should not interfere with them.

Is there a reproduction repo?

@pcorey
Copy link

pcorey commented Jun 9, 2016

@mitar @jsep @rbabayoff Here's a reproduction repo: https://github.com/pcorey/practicalmocha-repro

I've found that a fix is to move peerlibrary:reactive-publish below practicalmeteor:mocha in my packages file. That seems to fix the publication errors and correctly sends headers/titles/metadata/etc... down to the client.

Not sure what's going on beyond that.

@mitar
Copy link

mitar commented Jun 9, 2016

Not sure how mocha instruments things? Does it modify publish endpoints in a general way? peerlibrary:reactive-publish does so, but it should not matter.

@jsep
Copy link

jsep commented Jun 9, 2016

Thanks you so much @pcorey I was able to reproduce the problem, and as you said if a move peerlibrary:reactive-publish bellow practicalmeteor:mocha the issue it's solve, which is very odd 😕

Here is what I found @mitar:

Error: Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
     at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9:1)
     at Object.defineProperties.active.get [as active] (packages/peerlibrary_server-autorun/packages/peerlibrary_server-autorun.js:268:1)
     at Object.Tracker._trackerInstance (packages/peerlibrary_server-autorun/packages/peerlibrary_server-autorun.js:209:1)
     at Subscription.publish._currentComputation (packages/peerlibrary_reactive-publish/packages/peerlibrary_reactive-publish.js:212:1)
     at Subscription.publish._installCallbacks (packages/peerlibrary_reactive-publish/packages/peerlibrary_reactive-publish.js:221:1)
     at Subscription.publish.added (packages/peerlibrary_reactive-publish/packages/peerlibrary_reactive-publish.js:284:1)
     at MeteorPublishReporter.added (packages/practicalmeteor_mocha/meteor/src/reporters/MeteorPublishReporter.coffee:113:18)
     at MeteorPublishReporter.added (packages/practicalmeteor_mocha/meteor/src/reporters/MeteorPublishReporter.coffee:1:1)
     at Runner.<anonymous> (packages/practicalmeteor_mocha/meteor/src/reporters/MeteorPublishReporter.coffee:88:12)
     at Runner.emit (events.js:117:20)

In order to report data to client we use a collection, but we don't use collection.insert(doc), instead we manually add documents to the publication, You can see the details HERE

I hope this can help you.

@mitar
Copy link

mitar commented Jun 9, 2016

What about this TODO?

@mitar
Copy link

mitar commented Jun 9, 2016

Can you try to check before @publisher.added('mochaServerRunEvents', doc._id, doc) if you are in a fiber? I think you are not and this is why you get an error. You are calling publisher's added method outside of Fiber which is not how Meteor expects it to be.

@jsep
Copy link

jsep commented Jun 9, 2016

Hello @pcorey @mitar @sprintup @fignuts @tmeasday

I just release candidate of the package that should solve this issue.

To test the package just add it with the version 2.4.5-rc3.1

meteor add practicalmeteor:mocha@2.4.5-rc3.1

You can use the repo that @pcorey created:

git clone https://github.com/pcorey/practicalmocha-repro.git
cd practicalmocha-repro
meteor add practicalmeteor:mocha@2.4.5-rc3.1
meteor test --driver-package practicalmeteor:mocha

Thanks!

@pcorey
Copy link

pcorey commented Jun 10, 2016

@jsep I still seem to be having issues with rc3.1... Following your steps (plus an npm i), I still see the MeteorPublishReporter.added errors.

@mitar
Copy link

mitar commented Jun 10, 2016

Which exactly error do you get?

@pcorey
Copy link

pcorey commented Jun 10, 2016

pcorey@lap ~/practicalmocha-repro> meteor test --driver-package practicalmeteor:mocha
[[[[[ Tests ]]]]]

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

=> App running at: http://localhost:3000/
I20160610-10:05:13.637(-4)? MochaRunner.runServerTests: Starting server side tests with run id Pfx3qtui7wWTb4STw
W20160610-10:05:13.638(-4)? (STDERR) MeteorPublishReporter.added: Can't send report data to client.
W20160610-10:05:13.638(-4)? (STDERR) MeteorPublishReporter.added: Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20160610-10:05:13.638(-4)? (STDERR) MeteorPublishReporter.added: Document: { _id: '4',
W20160610-10:05:13.638(-4)? (STDERR)   event: 'suite',
W20160610-10:05:13.638(-4)? (STDERR)   data:
W20160610-10:05:13.638(-4)? (STDERR)    { title: 'foo',
W20160610-10:05:13.639(-4)? (STDERR)      root: false,
W20160610-10:05:13.639(-4)? (STDERR)      pending: false,
W20160610-10:05:13.639(-4)? (STDERR)      _fullTitle: 'foo',
W20160610-10:05:13.639(-4)? (STDERR)      isServer: true } }
W20160610-10:05:13.639(-4)? (STDERR) MeteorPublishReporter.added: Can't send report data to client.
W20160610-10:05:13.639(-4)? (STDERR) MeteorPublishReporter.added: Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20160610-10:05:13.639(-4)? (STDERR) MeteorPublishReporter.added: Document: { _id: '7',
W20160610-10:05:13.639(-4)? (STDERR)   event: 'suite end',
W20160610-10:05:13.639(-4)? (STDERR)   data:
W20160610-10:05:13.639(-4)? (STDERR)    { title: 'foo',
W20160610-10:05:13.639(-4)? (STDERR)      root: false,
W20160610-10:05:13.639(-4)? (STDERR)      pending: false,
W20160610-10:05:13.640(-4)? (STDERR)      _fullTitle: 'foo',
W20160610-10:05:13.640(-4)? (STDERR)      isServer: true } }
W20160610-10:05:13.640(-4)? (STDERR) MeteorPublishReporter.added: Can't send report data to client.
W20160610-10:05:13.640(-4)? (STDERR) MeteorPublishReporter.added: Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20160610-10:05:13.640(-4)? (STDERR) MeteorPublishReporter.added: Document: { _id: '8',
W20160610-10:05:13.640(-4)? (STDERR)   event: 'suite end',
W20160610-10:05:13.640(-4)? (STDERR)   data:
W20160610-10:05:13.640(-4)? (STDERR)    { title: '',
W20160610-10:05:13.641(-4)? (STDERR)      root: true,
W20160610-10:05:13.641(-4)? (STDERR)      pending: false,
W20160610-10:05:13.641(-4)? (STDERR)      _fullTitle: '',
W20160610-10:05:13.641(-4)? (STDERR)      isServer: true } }
W20160610-10:05:13.641(-4)? (STDERR) MeteorPublishReporter.added: Can't send report data to client.
W20160610-10:05:13.641(-4)? (STDERR) MeteorPublishReporter.added: Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20160610-10:05:13.641(-4)? (STDERR) MeteorPublishReporter.added: Document: { _id: '9',
W20160610-10:05:13.642(-4)? (STDERR)   event: 'end',
W20160610-10:05:13.642(-4)? (STDERR)   data:
W20160610-10:05:13.642(-4)? (STDERR)    { total: 1,
W20160610-10:05:13.642(-4)? (STDERR)      suites: 1,
W20160610-10:05:13.642(-4)? (STDERR)      tests: 1,
W20160610-10:05:13.642(-4)? (STDERR)      passes: 1,
W20160610-10:05:13.642(-4)? (STDERR)      pending: 0,
W20160610-10:05:13.642(-4)? (STDERR)      failures: 0,
W20160610-10:05:13.642(-4)? (STDERR)      start: Fri Jun 10 2016 10:05:13 GMT-0400 (EDT),
W20160610-10:05:13.642(-4)? (STDERR)      end: Fri Jun 10 2016 10:05:13 GMT-0400 (EDT),
W20160610-10:05:13.642(-4)? (STDERR)      duration: 22 } }
W20160610-10:05:13.643(-4)? (STDERR) MochaRunner.runServerTests: failures: 0

Also potentially of interest:

pcorey@lap ~/practicalmocha-repro> cat .meteor/packages | grep mocha
# Move reactive-publish below practicalmeteor:mocha to fix issue
practicalmeteor:mocha@2.4.5-rc3.1
pcorey@lap ~/practicalmocha-repro> meteor list | grep mocha
practicalmeteor:mocha            2.4.5_2  Write package tests with mocha and ...

@jsep
Copy link

jsep commented Jun 10, 2016

@pcorey for some reason it's not running the latest version 😕 , try to do a meteor reset

To be sure that you are running the correct version you can do this:

import { MochaRunner } from 'meteor/practicalmeteor:mocha'

console.log('Version of Mocha:', MochaRunner.VERSION)

@mitar
Copy link

mitar commented Jun 10, 2016

You have to do:

meteor add practicalmeteor:mocha@=2.4.5-rc3.1

(Notice = there.)

@pcorey
Copy link

pcorey commented Jun 10, 2016

Ah, whoops.

It looks like rc3.1 fixed the issue. Thanks @jsep and @mitar!

@sprintup
Copy link

This is great. I ran it and it solved the error that was displayed to the console. However, my project is not displaying the test reporter and I'm at a loss for what to do next. Any help would be appreciated:

Thank you

@rbabayoff
Copy link
Member

@sprintup it works for us with meteor 1.3.3 and our test app on ubuntu 14.04 and latest chrome. Can you:

  1. Post the command line you're using?
  2. Try it with meteor 1.3.3?
  3. Let us know the browser and version?
  4. If possible, create a meteor app repo that reproduces the problem?

@sprintup
Copy link

Thank you @rbabayoff I figured it out while trying to recreate the issue. It was the order of the packages in the packages file.

@mitar
Copy link

mitar commented Jun 16, 2016

The order of packages should not matter anymore? Are you using the release candidate?

@mitar
Copy link

mitar commented Jun 16, 2016

Yes, it is known that reordering of packages can help. But the important part is that we should fix is so that it works even without.

@jsep jsep mentioned this issue Jun 17, 2016
jsep pushed a commit that referenced this issue Jun 18, 2016
Version 2.4.5_3. Various improvements and bug fixes. Fixes #23 #42 #44 #45.

See new Changelog for details.
@jsep jsep closed this as completed Jun 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants