【发布时间】:2016-09-12 03:11:52
【问题描述】:
我正在使用 Atom 和 Mocha Test Runner。我收到 ReferenceError: DEV is not defined 当我尝试针对 React-Native (0.33) 运行测试时
DEV 变量在各种 react-native 核心模块中被引用。
我的 mocha 测试运行器选项是: --compilers js:babel-register --opts test/mocha.opts --harmony-proxies test/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
};
知道如何处理吗?
【问题讨论】:
标签: react-native mocha.js atom-editor