如何在 Velocity 集成测试中等待用户登录
How to wait for the user to be logged in, in Velocity integration tests
为了执行我的集成测试,必须执行来自 Meteor.loginWithPassword(...
的回调。
如果我推迟测试直到用户存在,或者定义了一些 Session
变量,测试将被忽略。
这是我的登录函数:
Meteor.loginWithPassword(username, forge.util.encode64(aesKey), function(error) {
if(!error) {
Log.info("user loged in");
Session.set("loggedIn", true);
...
})
然后在摩卡测试中:
Meteor.startup(function () {
Tracker.autorun(function (c) {
if (Session.get("loggedIn")) {
c.stop();
MochaWeb.testOnly(function () {
Log.info("executing tests");
describe("the KeyPair has been created", function () {
...
我的问题是:有没有办法让 mocha 等待某个状态,或者我是否必须模拟环境(这会破坏集成测试的目的)?
此外,在代码更改时,我收到以下错误:
stream error Network error: ws://localhost:51366/websocket: connect ECONNREFUSED
感谢您的支持
@stubailo 指出的功能请求现已实现。有关详细信息,请参阅 https://github.com/meteor/meteor/issues/3572。
为了执行我的集成测试,必须执行来自 Meteor.loginWithPassword(...
的回调。
如果我推迟测试直到用户存在,或者定义了一些 Session
变量,测试将被忽略。
这是我的登录函数:
Meteor.loginWithPassword(username, forge.util.encode64(aesKey), function(error) {
if(!error) {
Log.info("user loged in");
Session.set("loggedIn", true);
...
})
然后在摩卡测试中:
Meteor.startup(function () {
Tracker.autorun(function (c) {
if (Session.get("loggedIn")) {
c.stop();
MochaWeb.testOnly(function () {
Log.info("executing tests");
describe("the KeyPair has been created", function () {
...
我的问题是:有没有办法让 mocha 等待某个状态,或者我是否必须模拟环境(这会破坏集成测试的目的)?
此外,在代码更改时,我收到以下错误:
stream error Network error: ws://localhost:51366/websocket: connect ECONNREFUSED
感谢您的支持
@stubailo 指出的功能请求现已实现。有关详细信息,请参阅 https://github.com/meteor/meteor/issues/3572。