This is a really quick example of how to get Meteor print an XML file that we can then use on CircleCi to run our unit tests.
Thanks a lot to @mfpinheiro, @pushplaybang and @warehouseman for helping out!!!
Steps to reproduce this
Create new meteor project
meteor create --full name
Install spacejam globally
npm install -g spacejam
see https://www.npmjs.com/package/spacejam
Run tests via http-reporter (works fine)
meteor test --driver-package=practicalmeteor:mocha
Open localhost:3000 to see your tests.
Run tests via console-reporter and FAIL #1
add console-reporter via meteor add practicalmeteor:mocha-console-runner
run tests via spacejam test --driver-package=practicalmeteor:mocha-console-runner --port 1231
this gives the ERROR:
spacejam test --driver-package=practicalmeteor:mocha-console-runner --port 1231
spacejam: spawning meteor
[[[[[ Tests ]]]]]
=> Started proxy.
=> Started MongoDB.
spacejam: meteor mongodb is ready
=> Started your app.
=> App running at: http://localhost:1231/
spacejam: meteor is ready
spacejam: spawning phantomjs
phantomjs: Running tests at http://localhost:1231/local using test-in-console
phantomjs: There is no route for the path: /local
http://localhost:1231/packages/kadira_flow-router.js?hash=9b5b21b3e949cd3f26a647dfd0ac5f7b7a18757a: 519
spacejam: phantomjs exited with code: 6
spacejam: killing meteor
spacejam: meteor killed with signal: SIGTERM
spacejam: Unhandled error in meteor client side code. Exiting.
FIX FlowRouter bug and fail again with new error FAIL #2
Install FlowRouter bugfix to make it compatible with test-modes
mkdir packages
cd packages
git clone https://github.com/thebarty/flow-router
NOTE: all the Folk does it this:
WOW - we get the next error now, when running spacejam test --driver-package=practicalmeteor:mocha-console-runner --port 1231
Users/thebarty/.meteor/packages/meteor-tool/.1.4.3_2.1r2jzvc++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20170327-07:30:04.995(2)? (STDERR) throw(ex);
W20170327-07:30:04.996(2)? (STDERR) ^
W20170327-07:30:04.996(2)? (STDERR)
W20170327-07:30:04.997(2)? (STDERR) Error: Can't find test driver package: practicalmeteor:mocha-console-runner
W20170327-07:30:04.997(2)? (STDERR) at packages/meteor.js:1031:13
W20170327-07:30:04.998(2)? (STDERR) at Function.time (/private/var/folders/j3/hmkt_82519vbmq40ccj1c97c0000gn/T/meteor-test-run13bnb8b/.meteor/local/build/programs/server/profile.js:309:28)
W20170327-07:30:04.999(2)? (STDERR) at /private/var/folders/j3/hmkt_82519vbmq40ccj1c97c0000gn/T/meteor-test-run13bnb8b/.meteor/local/build/programs/server/boot.js:312:13
W20170327-07:30:04.999(2)? (STDERR) at /private/var/folders/j3/hmkt_82519vbmq40ccj1c97c0000gn/T/meteor-test-run13bnb8b/.meteor/local/build/programs/server/boot.js:353:5
W20170327-07:30:05.000(2)? (STDERR) at Function.run (/private/var/folders/j3/hmkt_82519vbmq40ccj1c97c0000gn/T/meteor-test-run13bnb8b/.meteor/local/build/programs/server/profile.js:510:12)
W20170327-07:30:05.001(2)? (STDERR) at /private/var/folders/j3/hmkt_82519vbmq40ccj1c97c0000gn/T/meteor-test-run13bnb8b/.meteor/local/build/programs/server/boot.js:351:11
=> Exited with code: 1
The final solution: use a different reporter
meteor remove practicalmeteor:mocha # avoid version-constrains
meteor add practicalmeteor:mocha-xunit-reporter
Then do a
spacejam test --driver-package=practicalmeteor:mocha-xunit-reporter --load-images=no --ssl-protocol=TLSv1 --xunit-out ./unit-tests.xml
This will generate a xml (hopefully compatible with CircleCi?) and output to console at the same time.
Thanks to Mateus @mfpinheiro