Skip to content

Commit 082e75b

Browse files
committed
refactor: remove getQueriesForElement alias
1 parent ee4d3d8 commit 082e75b

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

src/__tests__/within.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { Text, TextInput, View } from 'react-native';
33

4-
import { getQueriesForElement, render, within } from '..';
4+
import { render, within } from '..';
55

66
test('within() exposes basic queries', async () => {
77
const rootQueries = await render(
@@ -80,6 +80,3 @@ test('within() exposes a11y queries', async () => {
8080
await expect(secondQueries.findAllByA11yHint('Same Hint')).resolves.toHaveLength(1);
8181
});
8282

83-
test('getQueriesForElement is alias to within', () => {
84-
expect(getQueriesForElement).toBe(within);
85-
});

src/pure.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export { fireEvent } from './fire-event';
44
export { render } from './render';
55
export { waitFor } from './wait-for';
66
export { waitForElementToBeRemoved } from './wait-for-element-to-be-removed';
7-
export { within, getQueriesForElement } from './within';
7+
export { within } from './within';
88

99
export { configure, resetToDefaults } from './config';
1010
export { isHiddenFromAccessibility, isInaccessible } from './helpers/accessibility';

website/docs/14.x/docs/api/misc/other.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# Other helpers
22

3-
## `within`, `getQueriesForElement` {#within}
3+
## `within` {#within}
44

55
```jsx
66
function within(element: HostElement): Queries {}
7-
8-
function getQueriesForElement(element: HostElement): Queries {}
97
```
108

11-
`within` (also available as `getQueriesForElement` alias) performs [queries](docs/api/queries) scoped to given element.
9+
`within` performs [queries](docs/api/queries) scoped to given element.
1210

1311
:::note
1412
Please note that additional `render` specific operations like `rerender`, `unmount`, `debug`, `toJSON` are _not_ included.

website/docs/14.x/docs/migration/v14.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,34 @@ await rerender(<MyComponent />);
264264
265265
**Note:** This change is included in the step-by-step migration guide for async `render` above.
266266
267+
### `getQueriesForElement` export removed
268+
269+
In v14, the `getQueriesForElement` export alias for `within` has been removed. You must use `within` instead.
270+
271+
**What changed:**
272+
273+
- `getQueriesForElement` is no longer exported from the main package
274+
- `within` is the only exported function for scoped queries
275+
- `getQueriesForElement` remains available internally but is not part of the public API
276+
277+
**Migration:**
278+
279+
Replace all `getQueriesForElement` imports and usage with `within`:
280+
281+
```ts
282+
// Before (v13)
283+
import { getQueriesForElement } from '@testing-library/react-native';
284+
285+
const queries = getQueriesForElement(element);
286+
287+
// After (v14)
288+
import { within } from '@testing-library/react-native';
289+
290+
const queries = within(element);
291+
```
292+
293+
**Note:** `getQueriesForElement` was just an alias for `within`, so the functionality is identical - only the import needs to change.
294+
267295
### `renderHook` is now async by default
268296
269297
In v14, `renderHook` is now async by default and returns a Promise. This change makes it compatible with React 19, React Suspense, and `React.use()`.

0 commit comments

Comments
 (0)