Package.on_test 即使在不测试时也会运行 [英] Package.on_test runs even when not testing

查看:55
本文介绍了Package.on_test 即使在不测试时也会运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我们的应用启动时的样子:

This is what our app looks like when starting:

=> Started proxy.
=> Started MongoDB.     
>>>>> IN ON_TEST
meteor-collection-management: updating npm dependencies -- mongodb...

啊.在meteor-collection-management/package.js(我们自己的包)中,有这个:

Argh. In meteor-collection-management/package.js (our own package), there is this:

Package.on_test(function(api) {
    console.log(">>>>> IN ON_TEST");
    Npm.depends({
      mongodb: "1.4.1"
    });
    api.use(['meteor-collection-management', 'tinytest', 'test-helpers']);
    api.add_files('tests/dbobject-test.js', ['client', 'server']);
    api.add_files('tests/enums-test.js', ['client', 'server']);
});

为什么 Package.on_test 正在运行?我没有在测试模式下运行,甚至没有在节点调试模式下运行.

Why is Package.on_test running? I am not running in test mode not even in node debug mode.

推荐答案

on 测试函数只是运行以构建依赖关系图,即使它实际上并未使用.我看到你也打开了一个问题.这里有更多关于它做什么的信息:https://github.com/meteor/meteor/blob/a40a6273953c0e18eddcd67919754814461c5dd4/tools/packages.js#L1434

The on test function just runs to build a dependency map, even though its not actually used. I see you've opened an issue on it too. Theres more info on what it does here: https://github.com/meteor/meteor/blob/a40a6273953c0e18eddcd67919754814461c5dd4/tools/packages.js#L1434

因此它构建了.test,并且需要运行该方法以获取所需的文件.Meteor 需要在项目运行之前知道它需要什么,这可能是两者都运行的原因.(包需要构建到单个文件中,与 Meteor 的其余部分略有不同)

So it builds out .test, and needs to run the method to get the required files. Meteor needs to know what it needs before the project can run, which is probably why both run. (Package's need to be built into single files, as slightly different to the rest of Meteor)

这篇关于Package.on_test 即使在不测试时也会运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆