本文介绍了如何在设备上的Cordova中使用Meteor(客户端)单元测试(使用Velocity with Jasmine)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个移动Meteor项目(Cordova + Ionic Framework + Angular-Meteor),单元测试设置为和。在浏览器中进行测试时,客户端测试按预期执行,但在移动设备上失败。测试服务器托管在localhost上,因此设备无法找到托管应用程序和测试服务器的计算机。如何将Velocity测试服务器主机从localhost更改为我的LAN IP地址?

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?

推荐答案

您需要设置 ROOT_URL 环境变量。我发现如果我的主要(不是单元测试)Meteor应用程序从192.168.0.222:3000提供,我的ROOT_URL变量应如下所示:

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

速度为客户端和服务器单元测试服务器使用不同的端口。 ROOT_URL变量中的3000将更改为相应的端口,并将使用192.168.0.222主机IP。

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.

以下是我的测试脚本在启动应用程序时的样子我的Android设备。请特别注意ROOT_URL变量:

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

这篇关于如何在设备上的Cordova中使用Meteor(客户端)单元测试(使用Velocity with Jasmine)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 02:49
查看更多