首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >摩卡测试反应-本机抛出ReferenceError:__DEV__未定义

摩卡测试反应-本机抛出ReferenceError:__DEV__未定义
EN

Stack Overflow用户
提问于 2016-09-12 03:11:52
回答 1查看 1.3K关注 0票数 2

我用的是Atom和Mocha测试跑步者。我得到了ReferenceError:当我尝试运行针对React的测试时,没有定义DEV (0.33)

DEV变量在各种反应本机核心模块中引用.

我的摩卡测试运行程序选项是:-编译器js:babel-寄存器-opts test/mocha.opts -和谐-代理测试/setup.js

我的setup.js看起来像这样

代码语言:javascript
复制
import chai from "chai";
import fs from 'fs';
import path from 'path';
import register from 'babel-core/register';
import chaiEnzyme from 'chai-enzyme';

const modulesToCompile = [
  'react-native',
  'react-native-tabs',
  'react-native-vector-icons',
  'react-native-mock',
  'react-native-parallax-scroll-view'
].map((moduleName) => new RegExp(`/node_modules/${moduleName}`));

function getBabelRC() {
  var rcpath = path.join(__dirname, '..', '.babelrc');
  var source = fs.readFileSync(rcpath).toString();
  return JSON.parse(source);
}

var config = getBabelRC();

config.ignore = function(filename) {
  if (!(/\/node_modules\//).test(filename)) {
    return false;
  } else {
    const matches = modulesToCompile.filter((regex) => regex.test(filename));
    const shouldIgnore = matches.length === 0;
    return shouldIgnore;
  }
}

register(config);

global.__DEV__ = true;
global.expect = chai.expect;
chai.use(chaiEnzyme());

require('react-native-mock/mock');
const React = require('react-native')
React.NavigationExperimental = {
  AnimatedView: React.View
};

知道怎么处理这事吗?

EN

回答 1

Stack Overflow用户

发布于 2016-09-12 03:22:08

看起来我在Mocha设置中删除了一个参数,应该是

代码语言:javascript
复制
--compilers js:babel-register --opts test/mocha.opts --harmony-proxies --require test/setup.js
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39442875

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档