如何为包含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
我让Jest调试了很多次并运行了很多次。由于某种原因,在这个回购(我是新手)调试器将停止在jest.js
但不会停在测试本身。测试:
it('opens the drawer and presses the reset button', async () => {
debugger; // never stops here
console.log('test should have stopped');
我正在运行的命令:
✗ node --inspect-brk node_modules/.bin/jest --runIn
我有一个现有的项目,使用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 (
我有一个世博会应用程序,并使用SDK 28。我的团队决定我们应该更新到最新版本,这意味着更新Reactive原住民(因为最新的SDK使用RN0.57)和Babel。
当我们更新依赖项并修复配置文件时,Jest开始给出以下错误:
TypeError: Cannot read property 'fetch' of undefined
at node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:6:12
at Object.<anonymous> (node_module
我学习了jest,使用react-native & expo为组件编写了我的第一个快照测试。我可以在没有Icon组件的情况下运行测试,该组件来自我的组件中的'react-native-vector-icons/MaterialIcons‘。但是,当我尝试使用前面提到的图标组件运行测试时,我得到了以下错误:
ReferenceError: You are trying to `import` a file after the Jest environment has been torn down.
at Object.get Text [as Text] (node_mod
我试图建立一个移动应用程序的类型记录,反应-母语,博览会和玩笑。当我试着做测试时:
FAIL src/components/Button/tests/Button.test.tsx
● Test suite failed to run
Cannot find module '@babel/runtime/helpers/interopRequireDefault' from 'node_modules/react-native/jest/setup.js'
at Resolver.resolveModule (node_modul
我已经安装了jest-expo,但是当我运行我的测试时,我得到一个错误: react-native/jest-preset contained different transformIgnorePatterns than expected
Invariant Violation: Native module cannot be null.
at invariant (node_modules/invariant/invariant.js:40:15)
at new NativeEventEmitter (node_modules/react-native/Libr
目前我正在使用jest来做react原生应用程序(expo CLI)的单元测试,但是在测试render时,我从react-native导入任何组件都是完全正常的,但是如果我从其他应用程序(比如react- native -ui-kitten)导入组件,这是完全正常的。将会出现错误,如下图所示。有没有人能帮帮我,提前谢谢! Here's when i do snapshot with react-native component When i do snapshot that exists kitten UI component I'm configure "trans
我有一个API类,我试图在一个React应用程序中使用它。
// API file
class API {
...
}
export default API;
// Other file
import API from "utils/API";
const api = new API();
我发现了一个错误:
TypeError: _API.default is not a constructor
但是..。好像我的默认设置好了?
我的Jest设置如下:
"jest": {
"setupFiles": [
"
我正在使用bare react原生测试驱动开发,并使用包jest和酶。我为UI组件安装了NativeBase。当我使用来自NativeBase的图标时,我得到了错误
FAIL src/screens/Welcome/Welcome.test.js
● Test suite failed to run
/Users/../node_modules/@expo/vector-icons/build/vendor/react-native-vector-icons/Fonts/AntDesign.ttf:1
({"Object.<anonymous>":functio
我正在使用原生react创建一个简单的移动应用程序。这个项目在模拟器上运行得很好,直到我添加了redux。我正在使用redux进行登录和注销;它实际上只是一个缩减程序和操作文件,用于在登录时将authedUser设置为注册用户名,在注销时设置为null。如果我在web浏览器上运行它,它可以正常工作,但不能在ios/android模拟器上运行。当通过react-native run-android在模拟器上运行时,我得到了上面的错误。当通过expo运行它时,我得到:不变冲突:“main”尚未注册。here is a screenshot of the error完全迷失了方向。有什么建议吗?
我有一个非常困难的时间得到Jest和运行我的RN博览会项目(这样我可以玩和学习它)。
FAIL screens/HomeScreen.test.js
● Test suite failed to run
The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo
在遵循了实现说明之后,我正在基于expo.io的react本机应用程序上实现jest,我已经能够在我的系统上成功通过jest测试
问题出在bitbucket管道上。我收到以下问题,管道出现故障
npx jest --ci
● Validation Error:
Module react-native/jest/hasteImpl.js in the haste.hasteImplModulePath option was not found.
<rootDir> is: /opt/atlassian/pipelines/agent/build
下面是我在package
当我创建一个新的React原生项目并运行npm审计时,我得到了9个漏洞。漏洞列表如下表所示:
│ High │ Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ ws │
├─────────
我安装了@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