A first implementation of Meteor app testing for 1.3

Thanks @rbabayoff - We’ve started building some units with this and it looks good! We’ve found we can also use some of the traditional node tools like nock for server side http mocks.

@rbabayoff Great work! Works really smoothly. Question… can I import chai’s describe and beforeEach functions from somewhere? I can’t stand seeing those red squigglies in my IDE.

ESLint has env: mocha for this - does your IDE have a way to configure that? (for example, I bet it doesn’t show a squiggle for window?)

Yes you are right my IDE does have that option. I suppose a better question is, should I be assuming the test runner functions are part of the environment, or should I explicitly import them. I guess I thought that because assert and expect are explicitly imported from the chai library, describe and beforeEach should be as well.

It doesn’t seem to be the way that mocha does it. They do have a “require” interface that lets you do it but I haven’t quite figured out how to do that with practicalmeteor:mocha. If someone does work it out, let me know, I’d prefer to use this syntax too.

@tmeasday, @threevl, sorry, didn’t quite understand the issue, describe and beforeEach are mocha functions, not chai functions. What am I missing?

@rbabayoff it would make sense for the practicalmeteor:mocha package to export the various describe/beforeEach/it functions, so then you could write code like

import { describe, beforeEach, it } from 'meteor/practicalmeteor:mocha'

describe('something', () => {
});
3 Likes

@tmeasday, ok, please create an issue for that.

Everyone, practicalmeteor:mocha@2.1.0_8 is now published for meteor 1.3. Check it out. you will get some “Unable to resolve some modules:” warnings, those are safe to ignore, if their origin is mocha. We’re working on eliminating those.

Done: Export mocha symbols · Issue #20 · practicalmeteor/meteor-mocha · GitHub

@ahmedakram can you please post a reproduction as an issue on the angular2-meteor repo with the latest Meteor 1.3 and Angular2-Meteor release?

So, I’ve been spending the past week building a new boilerplate for the Clinical Meteor track using React and Meteor 1.3. Lots of great improvements so far. The meteor test --driver-package practicalmeteor:mocha --port 5000 works great, no problems. However, when I try to use the practicalmeteor:mocha-console-runner like so:

meteor test --full-app --driver-package=practicalmeteor:mocha-console-runner --port 5000

I keep getting the following error:

Any thoughts on why mocha-console-runner might not be picking up the /imports/**/test[s].js files?

Ah, mocha-console-runner still not quite working, but found a workaround with the following:

meteor test --driver-package dispatch:mocha-phantomjs --port 5000 --once

Yes!! https://github.com/meteor/meteor/issues/6901

Either downgrade to 1.3.1 or wait for 1.3.3 to get this working :wink:

1 Like

@tmeasday is it possible to specifically ignore files with names including *.test.* or *.spec.* ?

Our app uses redux-form and the the build is hitting a snag due to test files within the package.

Here’s the log.

=> Errors prevented startup:

While processing files with templating (for target web.browser):
node_modules/redux-form/coverage/lcov-report/src/events/tests/createOnBlur.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/events/tests/createOnChange.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/events/tests/createOnDragStart.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/events/tests/createOnDrop.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/events/tests/createOnFocus.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/events/tests/getValue.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/events/tests/isEvent.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/events/tests/silenceEvent.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/events/tests/silenceEvents.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/actions.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/asyncValidation.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/bindActionData.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/createReduxForm.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/fieldValue.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/getDisplayName.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/getValues.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/getValuesFromState.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/handleSubmit.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/initializeState.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/isPristine.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/isValid.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/mapValues.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/read.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/readField.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/readFields.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/reducer.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/removeField.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/resetState.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/setErrors.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/updateField.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/wrapMapDispatchToProps.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/wrapMapStateToProps.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)
node_modules/redux-form/coverage/lcov-report/src/tests/write.spec.js.html:1: Can’t set DOCTYPE here. (Meteor sets for you)

@dangroch - it seems weird meteor would pick up non-required files from inside node_modules. What version of Meteor is this? Can you reproduce with a simple project? It sounds like a bug.

@tmeasday I have also got such error and I prepared an env for you to check it out.

Basically, it seems that is looking up for .test and .spec files within the node_modules folder on execute tests. I have tried to run meteor-test command limiting the folder to search in. But it is still happening, so as you stated, this is likely a bug.

1 Like

Thankyou @gwerm1989 - https://github.com/meteor/meteor/issues/7494

Hi I’m trying to run tests on my meteor application, but for some reason hopefully you can help :slight_smile:
I get
Error can't find test driver package: practicalmeteor:mocha-console-runner

The command I’m running is meteor test --driver-package=practicalmeteor:mocha-console-runner --port 3300 --settings config/settings.dev-jlacey.json

I have tests in ./tests and ./packages/*/tests/example.tests.js

I don’t think its a problem with mocha-console-runner, because I get this error when running mocha-phantomjs, on the last couple of lines you will see Error: Can’t find test driver package: dispatch:mocha-phantomjs also

Thanks in advance for your help on this.

2016-10-18T15:36:32 [CRITICAL] QNetworkReplyImpl: backend error: caching was enabled after some bytes had been written
I20161018-15:36:32.819(1)? TypeError: undefined is not an object (evaluating 'Package.modules.meteorInstall')
I20161018-15:36:32.819(1)?                    
I20161018-15:36:32.820(1)?   phantomjs://code/phantomjsScript.js:15 in onError
I20161018-15:36:32.820(1)?     http://localhost:3300/packages/promise.js?hash=2d5b025794b9c9e54e5cf6bea71c642ef921a2ed: 17
I20161018-15:36:32.820(1)?                    
I20161018-15:36:32.820(1)?   phantomjs://code/phantomjsScript.js:17
I20161018-15:36:32.820(1)? TypeError: undefined is not an object (evaluating 'Package.modules.meteorInstall')
I20161018-15:36:32.820(1)?                    
I20161018-15:36:32.820(1)?   phantomjs://code/phantomjsScript.js:15 in onError
I20161018-15:36:32.820(1)?     http://localhost:3300/packages/ecmascript-runtime.js?hash=e4dd2b138377d446dc7dc3af21bb5bcd4b2b88a3: 17
I20161018-15:36:32.821(1)?                    
I20161018-15:36:34.279(1)?   phantomjs://code/phantomjsScript.js:17
.....
I20161018-15:36:34.279(1)? Error: Can't find test driver package: dispatch:mocha-phantomjs
.......
I20161018-15:36:34.279(1)? http://localhost:3300/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:1019:82
I20161018-15:36:34.279(1)? maybeReady@http://localhost:3300/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:809:28
I20161018-15:36:34.279(1)? loadingCompleted@http://localhost:3300/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:821:15