2016-12-06 32 views
1

我正在Meteor JS开发一个简单的Web应用程序。 我想用practicalmeteor运行测试:摩卡 所以我跑无法运行使用实用流星的流星测试:摩卡 - 文件结构问题

meteor add practicalmeteor:mocha 

,我可以正常启动有这个

running in test mode

的问题是我在测试模式流星应用试图添加测试并运行它,但我不知道该把它放在哪里。

我在一个名为“测试”项目的根目录中创建一个文件夹,把文件名为test.tests.js,该文件的内容是:

import { Meteor } from 'meteor/meteor'; 
import { Random } from 'meteor/random'; 
import { assert } from 'meteor/practicalmeteor:chai'; 


describe('movie_db',function({ 

    it('can view only existing movies',() => { 
     // Find the internal implementamtion of the task method so we can 
     // test it in isolation 
     const result = movies.find({name: "adsgfdfhggfsd"}).count(); 

     // Verify that the method does what we expected 
     assert.equal(result, 0); 
    }); 

})); 

,但没有在页面发生与测试结果,我仍然有0通和0失败(就好像没有任何测试写)。

所以我需要知道我该怎么做才能运行这些测试。

==============编辑===========================

当我将测试放入服务器或客户机文件夹时,它工作正常。 客户端在客户端文件夹中进行测试,服务器在服务器文件夹中进行测试。

回答

1

这个文档还不清楚,但基本上当您使用practicalmeteor进行测试时:mocha,您希望将测试另存为.tests.js,但不保存在/ tests文件夹中。

如果他们在/测试文件夹中,他们将不会被看到。希望可以帮助

+0

当我将客户端测试放入客户端文件夹并且服务器测试到测试文件夹时,它起作用。 如您所述,测试文件应以.tests.js结尾。 谢谢:) –