处理从0.52升级到RN 0.59.10时的babel / jest问题。任何帮助,具体的或定向的,都是非常感谢的。
我们的测试通过了RN 0.52。我希望这些是配置问题,而不是结构问题。
问题:调用/构造函数错误。有几个测试在deps中的超级调用(如RN的EventEmitter)或新的新调用(结果对象未定义)上失败。
示例:
test suite failed to run
TypeError: Cannot read property 'call' of undefined
at new RCTDeviceEventEmitter (node_modu
我安装了@react-native-firebase的v6,它按预期工作,但当我尝试运行单元测试时,我得到了以下错误:
Jest encountered an unexpected token
Details:
/node_modules/@react-native-firebase/database/lib/index.js:18
import { isBoolean, isNumber, isString } from '@react-native-firebase/app/lib/common';
^
SyntaxError: Unexpected t
是否可以在react-native项目中使用jest,这些项目使用来自react-native-elements的组件
示例jest文件工作得很好。一旦我将<Text>组件从react-native版本更改为react-native-elements版本,我就会得到以下错误消息。
● Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependenc
我是React Native的新手,你能帮我吗?我刚刚安装了react-native- sensors (Yarn add --保存react-native-sensors),然后我导入了我的项目(从“react-native -sensors”导入{ Accelerometer };),但我收到了这条信息:"Native Modules for sensors not available. Did -native link run?“
我运行了命令"react-native link react-native-sensors",但错误仍然存在=(
我使用的是"
如何为包含NavigationEvents子组件的react本机组件编写一个jest单元测试。
我尝试过在和问题中提供的解决方案,但都没有成功。
我所犯的错误是
console.error node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9215
The above error occurred in the <Context.Consumer> component:
in withNavigation(NavigationEvents) (cre
我正试图取笑一个新的react-native项目。但是,当我运行npm run test时,我会得到以下错误ReferenceError: __DEV__ is not defined。关于这个问题,我已经看过无数的Github问题和Stack溢出帖子,但是没有一个建议在我的案例中有效。
这是我的jest.config.js文件:
module.exports = {
transformIgnorePatterns: [
"node_modules/(?!(react-native|react-native-button|react-native-video)/)
没有任何与PropTypes相关的问题,因为我已经看到了与此相关的数十个问题,我的错误直接引用了‘seen _1.default.Component’,未定义的对象不是一个对象。
有人撞到这个错误了吗?我应该在这里上传哪些文件?
import React from 'react';
import { StackNavigator } from 'react-navigation';
import SideMenu from 'react-native-side-menu';
import Home from './app/screen
简单地说,我现有的在没有.bablerc的情况下工作,我只能让Jest使用一个.babelrc (因为我使用es6语法),一旦我添加了.babelrc,我的React原生应用程序就会出现以下错误。
在添加.babelrc之后,我在我的react原生服务器中看到了几个.babelrc不存在的BABEL注释。下面是一个示例(我在node_modules之前删除了路径),尽管我不认为这是一个问题
[BABEL] Note: The code generator has deoptimised the styling of "/node_modules/react-native-ht
我有一个现有的项目,使用React Native和Expo。目前,该应用程序运行良好。我正在尝试将Jest集成到项目中。jest中的基本"true=true“测试通过并运行时没有错误。但是,当我尝试使用ES6术语运行任何代码时,出现以下错误: FAIL screens/__tests__/home.test.js
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file whi
允许我将应用程序状态的逻辑放在一个位置(并避免redux)。现在它看起来像这样
// Using the Context API used in react 16.3 - https://www.youtube.com/watch?v=XLJN4JfniH4
const { Provider, Consumer: ContextConsumer } = React.createContext()
class ContextProvider extends Component {
...// lot of functions ...
render() {
return (
当我运行jest时,我会得到以下错误。看起来原因是与类型记录相关的,但是我在package.json中有一些类型记录处理,所以我不知道为什么它不会被处理。
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
...
Details:
/Users/ryancocuzzo/ex/test/example/mobile-a
我正在向我的React Native项目添加Jest测试框架。我得到以下错误:
Failed to get mock metadata: /Users/me/Documents/Development/project/node_modules/global/window.js
我的测试文件如下所示:
import 'react-native'
import React from 'react'
import { MyComponent } from '../components/MyComponent'
import renderer from
我正在使用和jest来测试我的React。我有一个很基本的测试,看起来是这样的:
import 'react-native';
import React from 'react';
import PushController from '../app/PushController';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('works correc