问题
I have a mobile Meteor project (Cordova + Ionic Framework + Angular-Meteor) with unit-tests set up with Velocity and Jasmine. When testing in the browser, the client tests execute as expected but fail on mobile devices. The test servers are hosted at localhost so the devices can't find my computer which hosts the app and test servers. How can I change the Velocity test servers host from localhost to my LAN IP address?
回答1:
You need to set your ROOT_URL
environment variable. I found that if my main (not unit-testing) Meteor app was serving up from 192.168.0.222:3000 that my ROOT_URL variable should look like this:
ROOT_URL="http://192.168.0.222:3000"
The velocity uses different ports for client and server unit test servers. The 3000 in the ROOT_URL variable will get changed to the appropriate ports and will use the 192.168.0.222 host IP.
Here's what my test script looks like for launching my app on my Android device. Note the ROOT_URL variable in particular:
echo
echo
echo "TIP: If you have changed IPs, delete your app from device first"
MONGO_URL="foo" \
MONGO_OPLOG_URL="bar" \
ROOT_URL="http://192.168.0.222:3000" \
VELOCITY_MONGO_URL="mongodb://127.0.0.1:27017/my_unit_test_db" \
meteor run android-device --mobile-server 192.168.0.222:3000
来源:https://stackoverflow.com/questions/34796936/how-can-i-get-meteor-client-unit-tests-using-velocity-with-jasmine-to-work-i