首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Jest TransformIgnorePatterns all node_modules for React-本机预设

Jest TransformIgnorePatterns all node_modules for React-本机预设
EN

Stack Overflow用户
提问于 2018-05-17 17:48:04
回答 1查看 23.9K关注 0票数 20

我是新来开玩笑的

在我的项目的- package.json中设置jest配置后,

Package.json

"jest": {
    "preset": "react-native",
    "verbose": true,
    "moduleDirectories": ["node_modules", "src"],
    "transformIgnorePatterns": ["node_modules/(?!(react-native-cookies)/)"]
  },

我已经尝试过忽略所有节点模块:

"transformIgnorePatterns": ["node_modules"]

但对我不起作用

.babelrc

{
  "presets": ["react-native"]
}

我的登录屏幕-测试.js代码:-

TestCase

import 'react-native';
import React from 'react';
import LoginScreen from '../src/components/LoginScreen';
import renderer from 'react-test-renderer';

it('renders correctly', () => {
  const hello = renderer.create(<LoginScreen/>).toJSON();
  expect(hello).toMatchSnapshot();
});

我开始运行--> npm test或npm test -u

它反映了我的以下错误:

终端输出

FAIL tests/LoginScreen-test.js测试套件运行失败

/Users/Documents/Projects/node_modules/react-native/Libraries/Utilities/Platform.ios.js:31 get isTesting():boolean {^ SyntaxError:意外标记:在ScriptTransformer._transformAndBuildScript isTesting at Object.get Platform as Platform at Object。(node_modules/react-native-cookies/index.js:9:17)

我想忽略TransformIgnorePattern的所有节点模块,但它似乎对我的React-Native预置无效。

寻找有用的答案...

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50388367

复制
相关文章

相似问题

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