我正在检查Meteor.startup中的测试文档,如果它不存在则创建它。我有以下mocha测试,并且testPage未定义,因此我在运行测试时不断获得Unspecified AssertionError
和timeout of 2000ms exceeded
。我做错了什么?
//文件app / server / bootstrap.js
Meteor.startup(function () {
/* create a test page */
if (Pages.find().count() === 0) {
Pages.insert({
display: false,
order: 0,
nav: 'Test Page',
content: '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris magna orci, semper eget arcu a, porta vehicula massa. Mauris ut interdum dui. Suspendisse potenti. Phasellus vel purus ac lectus faucibus tincidunt vel id neque. Donec blandit eros non odio dapibus, ut venenatis dui um lectus quis neque porta, in viverra quam tincidunt. Aliquam nec pharetra ipsum. Proin et pretium mi, vel aliquet arcu.</p>'
});
}
});
//文件app / tests / mocha / sampleServerTest.js
if (typeof MochaWeb !== 'undefined') {
MochaWeb.testOnly(function(){
describe("Data initialization", function() {
it ("should have a test document", function() {
var testPage = Pages.findOne({display: false});
console.log('testPage', testPage);
chai.assert(testPage);
});
});
});
}