Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

react-native-testing-library

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-testing-library - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

src/waitForElement.js

9

package.json
{
"name": "react-native-testing-library",
"version": "0.2.2",
"version": "0.2.3",
"description": "Simple React Native testing utilities helping you write better tests with less effort",
"main": "src/index.js",
"typings": "./typings/index.d.ts",
"repository": "git@github.com:callstack/react-native-testing-library.git",

@@ -14,2 +15,4 @@ "author": "Michał Pierzchała <thymikee@gmail.com>",

"@callstack/eslint-config": "^2.0.0",
"@types/react": "^16.4.15",
"@types/react-test-renderer": "^16.0.3",
"babel-core": "7.0.0-bridge.0",

@@ -23,3 +26,4 @@ "babel-jest": "^23.6.0",

"react": "^16.5.2",
"react-test-renderer": "^16.5.2"
"react-test-renderer": "^16.5.2",
"typescript": "^3.1.1"
},

@@ -37,4 +41,5 @@ "peerDependencies": {

"flow-check": "flow check",
"typescript-check": "tsc --noEmit --skipLibCheck --jsx react ./typings/__tests__/*",
"lint": "eslint src --cache"
}
}

@@ -10,3 +10,3 @@ # react-native-testing-library

[![Chat][chat-badge]][chat]
[![Greenkeeper badge](https://badges.greenkeeper.io/callstack/react-native-testing-library.svg)](https://greenkeeper.io/)
[![Greenkeeper badge][greenkeeper-badge]][greenkeeper]

@@ -258,2 +258,28 @@ _Appreciation notice: This project is heavily inspired by [react-testing-library](https://github.com/kentcdodds/react-testing-library). Go check it out and use it to test your web React apps._

## `waitForElement`
Defined as:
```jsx
function waitForExpect<T: *>(
expectation: () => T,
timeout: number = 4500,
interval: number = 50
): Promise<T> {}
```
Wait for non-deterministic periods of time until your element appears or times out. `waitForExpect` periodically calls `expectation` every `interval` milliseconds to determine whether the element appeared or not.
```jsx
import { render, waitForElement } from 'react-testing-library';
test('waiting for an Banana to be ready', async () => {
const { getByText } = render(<Banana />);
await waitForElement(() => getByText('Banana ready'));
});
```
If you're using Jest's [Timer Mocks](https://jestjs.io/docs/en/timer-mocks#docsNav), remember not to use `async/await` syntax as it will stall your tests.
## `debug`

@@ -324,1 +350,3 @@

[chat]: https://discord.gg/QbGezWe
[greenkeeper-badge]: https://badges.greenkeeper.io/callstack/react-native-testing-library.svg?style=flat-square
[greenkeeper]: https://greenkeeper.io/

@@ -7,2 +7,3 @@ // @flow

import fireEvent from './fireEvent';
import waitForElement from './waitForElement';

@@ -14,1 +15,2 @@ export { render };

export { fireEvent };
export { waitForElement };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc