我用的是Atom和Mocha测试跑步者。我得到了ReferenceError:当我尝试运行针对React的测试时,没有定义DEV (0.33)
DEV变量在各种反应本机核心模块中引用.
我的摩卡测试运行程序选项是:-编译器js:babel-寄存器-opts test/mocha.opts -和谐-代理测试/setup.js
我的setup.js看起来像这样
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
};知道怎么处理这事吗?
发布于 2016-09-12 03:22:08
看起来我在Mocha设置中删除了一个参数,应该是
--compilers js:babel-register --opts test/mocha.opts --harmony-proxies --require test/setup.jshttps://stackoverflow.com/questions/39442875
复制相似问题