mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
feat(testing-library__dom): add screen export (#41052)
This commit is contained in:
4
types/testing-library__dom/index.d.ts
vendored
4
types/testing-library__dom/index.d.ts
vendored
@@ -1,10 +1,11 @@
|
||||
// Type definitions for @testing-library/dom 6.10
|
||||
// Type definitions for @testing-library/dom 6.11
|
||||
// Project: https://github.com/testing-library/dom-testing-library
|
||||
// Definitions by: Alex Krolick <https://github.com/alexkrolick>
|
||||
// Kent C Dodds <https://github.com/kentcdodds>
|
||||
// Sebastian Silbermann <https://github.com/eps1lon>
|
||||
// Weyert de Boer <https://github.com/weyert>
|
||||
// Ronald Rey <https://github.com/reyronald>
|
||||
// Justin Hall <https://github.com/wKovacs64>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
@@ -17,6 +18,7 @@ export { queries, queryHelpers, within };
|
||||
|
||||
export * from './queries';
|
||||
export * from './query-helpers';
|
||||
export * from './screen';
|
||||
export * from './wait';
|
||||
export * from './wait-for-dom-change';
|
||||
export * from './wait-for-element';
|
||||
|
||||
6
types/testing-library__dom/screen.d.ts
vendored
Normal file
6
types/testing-library__dom/screen.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { BoundFunctions, Queries } from './get-queries-for-element';
|
||||
import * as queries from './queries';
|
||||
|
||||
export type Screen<Q extends Queries = typeof queries> = BoundFunctions<Q>;
|
||||
|
||||
export const screen: Screen;
|
||||
@@ -1,8 +1,9 @@
|
||||
import { queries, isInaccessible } from '@testing-library/dom';
|
||||
import { queries, screen, isInaccessible } from '@testing-library/dom';
|
||||
|
||||
const { getByText, queryByText, findByText, getAllByText, queryAllByText, findAllByText, queryByRole } = queries;
|
||||
|
||||
async function testQueries() {
|
||||
// element queries
|
||||
const element = document.createElement('div');
|
||||
getByText(element, 'foo');
|
||||
queryByText(element, 'foo');
|
||||
@@ -10,6 +11,14 @@ async function testQueries() {
|
||||
getAllByText(element, 'bar');
|
||||
queryAllByText(element, 'bar');
|
||||
await findAllByText(element, 'bar');
|
||||
|
||||
// screen queries
|
||||
screen.getByText('foo');
|
||||
screen.queryByText('foo');
|
||||
await screen.findByText('foo');
|
||||
screen.getAllByText('bar');
|
||||
screen.queryAllByText('bar');
|
||||
await screen.findAllByText('bar');
|
||||
}
|
||||
|
||||
function testByRole() {
|
||||
@@ -18,6 +27,9 @@ function testByRole() {
|
||||
|
||||
console.assert(queryByRole(element, 'button') === null);
|
||||
console.assert(queryByRole(element, 'button', { hidden: true }) !== null);
|
||||
|
||||
console.assert(screen.queryByRole('button') === null);
|
||||
console.assert(screen.queryByRole('button', { hidden: true }) !== null);
|
||||
}
|
||||
|
||||
function testA11yHelper() {
|
||||
|
||||
Reference in New Issue
Block a user