我有一个流星应用程序,我尝试编写以下测试:
if (Meteor.isClient) {
describe('System', () => {
describe('check that the system is not active', () => {
it('DB table is updated', () => {
HTTP.post(server + "/system", {"data":{"active": "0"}}, function () {console.log("POST sent")});
Tracker.autorun((computation) => {
if (!System.findOne({}) || (System.findOne({}) && System.findOne({}).active)) {console.log("waiting");return;}
computation.stop();
});
return assert.equal(System.findOne({}).active, false);
});
it('Can see it active in UI', () => {
return assert.equal($('.status').text().trim(), "The system is not active");
});
});
describe('check that the system is active', () => {
it('DB table is updated', () => {
HTTP.post(server + "/system", {"data":{"active": "1"}}, function () {console.log("POST sent")});
Tracker.autorun((computation) => {
if (!(System.findOne({}) && System.findOne({}).active)) {return;}
computation.stop();
});
return assert.equal(System.findOne({}).active, true);
});
it('Can see it active in UI', () => {
return assert.equal($('.status').text().trim(), "The system is active");
});
});
});
}
我的问题是,只有在第二次测试结束后我才能进入第一次测试的追踪器并且我的所有结果都不值得。 我想在开始运行另一个测试之前以某种方式等待Tracker。
我尝试过afterFlushPromise,waitForSubscriptions,Tracker.flush()甚至从流星文档中去除了deodeify,但似乎没有任何帮助。
有人有想法吗?