小编mad*_*ion的帖子

开玩笑:如何修复 - TypeError:无法分配给函数“function () 的只读属性“名称”

我在我自己的功能组件中使用react-native-paper。我想为我的组件编写 Jest 测试。

问题:当我将组件导入 Jest 测试文件时,我收到此错误:

TypeError: Cannot assign to read only property 'name' of function 'function () {for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {ar...<omitted>... }'
at node_modules/react-native-paper/src/core/withTheme.js:136:46
   at Array.forEach (<anonymous>)
at withTheme (node_modules/react-native-paper/src/core/withTheme.js:124:5)
at Object.<anonymous> (node_modules/react-native-paper/src/components/Typography/Text.js:46:24)
at Object.<anonymous> (node_modules/react-native-paper/src/components/BottomNavigation.js:16:48)`
Run Code Online (Sandbox Code Playgroud)

试图缩小错误范围,我发现即使是这个简单的 Jest 文件也会导致错误。

复制器

import React from 'react';
import { Provider as PaperProvider } from 'react-native-paper';

describe('Unit Tests - Component:', () => {
  it('s a test', () => {}); …
Run Code Online (Sandbox Code Playgroud)

jestjs react-native

7
推荐指数
2
解决办法
3万
查看次数

标签 统计

jestjs ×1

react-native ×1