meteor - 在服务器运行时使用 tinytest 测试 Meteor 客户端

标签 meteor

是否可以在服务器运行时使用 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/

相关文章:

javascript - 显示来自 Meteor 1.0 的数据

javascript - meteor :如何发布依赖于其他集合游标的游标

meteorjs meteor 用户状态 mizzao 包 : cannot get other users

javascript - 范围错误: Maximum call stack size exceeded when I create a project in Meteor

node.js - 从 DevOps Services 部署 Meteor 应用程序时,如何在 IBM Bluemix 上安装所需的包?

javascript - 在 Meteor.js 中创建秒表

javascript - 如何在流量路由器中使用订阅?

meteor - 停止对一个变量的 react

asynchronous - 编写/转换 Meteor 同步函数

node.js - Meteor Mongo BulkOp 将 ObjectID 转换为普通对象