Joshua
Joshua

Reputation: 6665

Is it possible to run my meteor tests in docker?

Once I've built my container with my Meteor app in it, I'd really like to be able to go

docker run me/myapp velocity test-app --ci --once --settings settings-test.json

And have it exit with 0 if successful, in which case I'll push it to docker hub, deploy it somewhere etc.

However when I try this it just hangs:

[velocity] is in continuous integration mode
[velocity] mocha is starting a mirror at http://localhost:56381/.
[velocity] *** Meteor Tools is installing *** 
This takes a few minutes the first time.
[velocity] You can see the mirror logs at: tail -/app/.meteor/local/log/mocha.log

I'm using jasmine as per https://github.com/meteor-velocity/velocity-examples (I started with Mocha, but switched over to see if it made any difference).

Inspecting my .meteor/local/log files I find jasmine-client- unit.log has this at the bottom:

WARN [watcher]: [39m Pattern "/app/tests/jasmine/client/unit/**/*-+(stub|stubs|mock|mocks).+(js|coffee|litcoffee|coffee.md)" does not match any file.
WARN [karma]: [39m No captured browser, open http://localhost:9876/
INFO [karma]: [39m Karma v0.13.9 server started at http://localhost:9876/
INFO [launcher]: [39m Starting browser Chrome
ERROR [launcher]: [39m No binary for Chrome browser on your platform.
Please, set "CHROME_BIN" env variable
Parent process ( 725 ) is dead! Exiting jasmine-client-unit

Chrome clearly isn't going to be available in docker - should phantomjs be installed at this point and specified as a the running option? I would have expected this to be the case by default if the --ci option has been specified?

Thanks.

Upvotes: 2

Views: 448

Answers (1)

ffxsam
ffxsam

Reputation: 27713

Ideally you should be using a real browser such as Chrome or Firefox to do automated testing, not PhantomJS. You can run browsers headlessly using Xvfb.

These might be useful:

http://codeutopia.net/blog/2013/07/13/headless-chromefirefox-testing-in-nodejs-with-selenium-and-xvfb/

http://elementalselenium.com/tips/38-headless

Selenium is the way to go for testing. IMO the best setup would be to use a CI server like Jenkins or TeamCity, with Xvfb installed, and have a test/deploy shell script in Jenkins such as:

#!/bin/sh

set -ex

cd $WORKSPACE
export VELOCITY_CI=1

meteor --test --settings $WORKSPACE/.deploy-staging/settings.json

cd .deploy-staging
mupx setup
mupx deploy

(Note that Xvfb is not implemented here, though). This test is not entirely working, I have yet to jump into Xvfb myself, though I know this is the right direction.

I'm using mupx to deploy my apps, which automatically creates a Docker instance on the remote server for me and handles deployment completely.

Upvotes: 3

Related Questions