tests.screen
Queries over what the last render shows.
Usage
Query the rendered screen.
// Query the rendered screen.
import { Button, Text, VStack } from 'kuito';
import { assert, render, screen, test } from 'kuito/tests';
const Empty = () => (
<VStack>
<Text>No messages yet</Text>
<Button>Write one</Button>
</VStack>
);
test('an empty inbox invites a first message', async () => {
await render(<Empty />);
assert.ok(screen.getByText('No messages yet'));
assert.ok(screen.getByRole('button', { name: 'Write one' }));
assert.equal(screen.queryByText('Inbox'), null);
});Properties and methods 6
| Name | Type | Required | Description |
|---|---|---|---|
getByText | (text: TextMatch) => TestView | Yes | The one view showing text; throws when none or several do. |
getAllByText | (text: TextMatch) => TestView[] | Yes | — |
queryByText | (text: TextMatch) => TestView | null | Yes | — |
getByRole | (role: string, options?: RoleOptions) => TestView | Yes | The one view with role (and name, when given); throws when none or several have it. |
getAllByRole | (role: string, options?: RoleOptions) => TestView[] | Yes | — |
queryByRole | (role: string, options?: RoleOptions) => TestView | null | Yes | — |
getByText — method signatures
Signatures
(text: TextMatch): TestViewParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | TextMatch | Yes | — |
Returns
TestView
getAllByText — method signatures
Signatures
(text: TextMatch): TestView[]Parameters
| Name | Type | Required | Description |
|---|---|---|---|
text | TextMatch | Yes | — |
Returns
TestView[]
queryByText — method signatures
Signatures
(text: TextMatch): TestView | nullParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | TextMatch | Yes | — |
Returns
TestView
getByRole — method signatures
Signatures
(role: string, options?: RoleOptions): TestViewParameters
| Name | Type | Required | Description |
|---|---|---|---|
role | string | Yes | — |
options | RoleOptions | No | — |
Returns
TestView
getAllByRole — method signatures
Signatures
(role: string, options?: RoleOptions): TestView[]Parameters
| Name | Type | Required | Description |
|---|---|---|---|
role | string | Yes | — |
options | RoleOptions | No | — |
Returns
TestView[]
queryByRole — method signatures
Signatures
(role: string, options?: RoleOptions): TestView | nullParameters
| Name | Type | Required | Description |
|---|---|---|---|
role | string | Yes | — |
options | RoleOptions | No | — |
Returns
TestView
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.