找不到模块“meteor”
我想从命令行用摩卡框架testingmeteor应用程序:
摩卡** / * / * spec.js – 编译器js:babel-core / register
所有的testing工作正常,但是当testing文件开始时:
import { Meteor } from 'meteor/meteor'; import { Factory } from 'meteor/dburles:factory';
导入meteor等。我收到错误:
错误:无法find模块“meteor/meteor”
所以我的问题是:
-
我怎样才能testing一个meteor应用程序没有命令“meteortesting”?
-
我如何引导摩卡运行meteortesting?
谢谢。
你需要使用实用的meteor:摩卡。 所以我有我的package.json中的脚本,如:
"scripts": { "start": "meteor --settings settings-development.json", "test": "meteor test --driver-package practicalmeteor:mocha --port 5000 --settings settings-development.json", "chimp-watch": "chimp --ddp=http://localhost:3000 --watch --mocha --path=tests", "chimp-test": "chimp --ddp=http://localhost:3000 --mocha --path=tests" },
这些是一些简单的testing:
/* eslint-env mocha */ /* eslint-disable func-names, prefer-arrow-callback */ /* eslint no-console: ["error", { allow: ["log", "warn", "error"] }] */ import { Meteor } from 'meteor/meteor'; import { assert } from 'meteor/practicalmeteor:chai'; import { resetDatabase } from 'meteor/xolvio:cleaner'; import { checkLog } from '../apiHelpers.js'; import { insertLog } from './methods.js'; import { addLog, addLogPromise } from './insertHelpers.js'; import { getLGSitemId, getLGSitemType, getLGScreateDate } from './generalHelpers.js'; import { getLDSevents, getLDSevent, addEvent } from './dataHelpers.js'; describe('Log Tests', function() { beforeEach(function () { if (Meteor.isServer) { resetDatabase(); } }); if (Meteor.isServer) { it('insertHelpers: addLog', function () { let testLogId = ''; try { testLogId = insertLog.call(addLog('someDodgyId', 'doc')); } catch (err) { console.log(err); } assert.typeOf(testLogId, 'string'); assert.typeOf(checkLog(testLogId), 'undefined'); // if it runs correctly, undefined }); it('insertHelpers: addLogPromise', function () { addLogPromise('someDodgyId', 'doc') .then((result) => { assert.typeOf(result, 'string'); assert.typeOf(checkLog(result), 'undefined'); }) .catch((err) => { throw new Meteor.Error(err); }); }); it('generalHelpers', function() { const testLogId = insertLog.call(addLog('someDodgyId', 'doc')); assert.typeOf(testLogId, 'string'); // Tests assert.equal(getLGSitemId(testLogId), 'someDodgyId'); assert.equal(getLGSitemType(testLogId), 'doc'); assert.typeOf(getLGScreateDate(testLogId), 'date'); }); } });
- 摩卡命令给ReferenceError:窗口没有定义
- 为什么使用supertest代替expressJS的unit testing?
- 你如何安装和运行Mocha,Node.jstesting模块? 安装后得到“mocha:command not found”
- 如何忽略伊斯坦布尔覆盖范围内node.js中的所需文件
- 使用mocha和node.js对私有函数进行unit testing
- 向Chai / Mocha提供应包含的部分密钥列表
- testing与Mockgoose失败导致MongoError:拓扑被破坏
- 使用摩卡混合同步和asynchronoustesting
- MochaJS:如何在testing之间共享断言/“它('应该')”代码