[英]Meteor/React Mocha tests using Enzyme - Cannot find module 'has'
如前所述,我正在使用React運行Meteor應用程序,並開始使用Mocha編寫測試。 目前,我有一個基本測試,什么也不測試。
客戶/潛在客戶/ProspectForm.tests.jsx
import React from 'react';
import { shallow } from 'enzyme';
describe('<Foo />', () => {
it('calls componentDidMount', () => {
});
});
當我啟動測試服務器時,出現以下錯誤
找不到模塊“有”。 看來問題出在酶上,但是當我創建一個新的流星應用程序並添加酶和實用的meteor:mocha,然后添加相同的測試時,它工作正常,因此它必須與此應用程序上的環境有關。
這是我的package.json
{
"name": "myApp",
"private": true,
"scripts": {
"start": "meteor run"
},
"dependencies": {
"material-ui": "^0.15.0",
"meteor-node-stubs": "~0.2.0",
"react": "^15.0.2",
"react-addons-pure-render-mixin": "^15.0.1",
"react-datepicker": "^0.27.0",
"react-dom": "^15.0.2",
"react-mounter": "^1.2.0",
"react-s-alert": "^1.1.4",
"react-tap-event-plugin": "^1.0.0"
},
"devDependencies": {
"enzyme": "^2.3.0"
}
}
這是我的流星包文件
# edgee:slingshot # Send files to storage service.
# peerlibrary:aws-sdk # Amazon SDK for S3/EC2/etc...
# CORE PACKAGES
meteor-base # Meteor platform
mobile-experience # Mobile Optimizations
logging # Meteor internal logging
ejson # Extends JSON Types
tracker # Reactive Data Sources
email # Send emails
accounts-password # Authentication for users.
es5-shim # ECMAScript 5 compatibility for older browsers.
ecmascript # Enable ECMAScript2015+ syntax
standard-minifier-css # CSS Minification
standard-minifier-js # Javascript Minification
static-html # Adds global head tag
reload # Active reload
react-meteor-data # Used for react data mixins
stevezhu:lodash # Javascript utility library.
momentjs:moment # Date library for Javascript.
johnantoni:meteor-normalize # normalizes css
fourseven:scss # SASS stylesheets.
fortawesome:fontawesome # Icons.
natestrauser:animate-css # Animations using CSS.
mongo # Mongo DB
aldeed:collection2 # Schemas and validations for database collections.
dburles:collection-helpers # Create data helpers in ./lib available to client and server.
meteortoys:allthings # A number of helpers for deveopment. Activate with control+m
kadira:flow-router # Router.
mystor:device-detection # Detect device user is using.
semantic:ui-css
practicalmeteor:mocha
有人知道這里發生了什么嗎?
如果還沒有這兩個依賴,則還需要安裝它們:
npm i --save-dev react-addons-test-utils
npm i --save-dev react-dom
看起來您具有react-dom,但您缺少test-utils。
運行流星更新為我解決了這個問題,我也必須按照戴文所說的去做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.