是否可以在服务器运行时使用 tinytest 测试 Meteor 客户端?这是我仅测试客户端的示例:
Tinytest.add("Add object to a collection", function(test) {
var people = new Meteor.Collection("people");
people.insert({"name": "Andrew"}, function(error, id) {
test.isNull(error);
});
});
这经过了几分之一秒,然后进入“等待”状态。我也肯定错误不是空的。
Meteor.Error {error: 404, reason: "Method not found", details: undefined}
我知道这种情况正在发生,因为它们不是客户端可以与之通信的服务器。当我尝试在服务器和客户端上运行此测试时,我继续遇到与客户端相同的问题。有没有办法在服务器运行时测试客户端?
谢谢,安德鲁
最佳答案
使用 new Meteor.Collection
没有参数来创建不需要服务器的 stub 集合。见 the docs on Collections :
If you pass null as the name, then you're creating a local collection. It's not synchronized anywhere; it's just a local scratchpad that supports Mongo-style find, insert, update, and remove operations.
关于meteor - 在服务器运行时使用 tinytest 测试 Meteor 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14985684/