首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在react本机中测试世博线性梯度,抛出TypeError:无法读取属性“包括”的未定义。

在react本机中测试世博线性梯度,抛出TypeError:无法读取属性“包括”的未定义。
EN

Stack Overflow用户
提问于 2022-08-04 12:06:14
回答 1查看 327关注 0票数 0

我的错误:

代码语言:javascript
复制
 TypeError: Cannot read property 'includes' of undefined

  at requireNativeViewManager (node_modules/expo-modules-core/src/NativeViewManagerAdapter.native.tsx:28:49)
  at Object.<anonymous> (node_modules/expo-linear-gradient/src/NativeLinearGradient.android.tsx:49:34)
  at Object.<anonymous> (node_modules/expo-linear-gradient/src/LinearGradient.tsx:4:1)

我的预设:

代码语言:javascript
复制
 projects: [
{ "preset": "jest-expo/ios" },
{ "preset": "jest-expo/android" },
{ "preset": "jest-expo/web" },

],

构成部分:

代码语言:javascript
复制
 <LinearGradient
      colors={colorsArray}
      style={{
        ...uikitStyles.progressBar,
        height: heightHandler(height).height,
        backgroundColor: bgColor,
        width: `${newWidth}%`,
      }}
      end={{ x: 1, y: 0 }}
      testID="gradient-test"
    />

错误的屏幕快照

我正在使用‘@ test -库/react本机’来编写测试用例,有人能帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2022-08-16 12:21:20

  1. 检查jest-世博版本和世博会。他们应该匹配。
  2. 查看您的jest.config.js (原始答案https://github.com/expo/expo/issues/8527#issuecomment-640103212):问题是,我使用@ jest库/expo作为我的玩笑预置,而不是jest-expo。在测试库预置的同时添加jest-expo预置到我的jest.config.js中,设法解决了这个问题: const expoPreset =需要量(‘jest-expo/jest-预设’);module.exports ={ ...expoPreset,预设:“@jest库/jest本机”,}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73235675

复制
相关文章

相似问题

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