tests.screen
Queries over what the last render shows.
Utilisation
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);
});Propriétés et méthodes 6
| Nom | Type | Requis | Description |
|---|---|---|---|
getByText | (text: TextMatch) => TestView | Oui | The one view showing text; throws when none or several do. |
getAllByText | (text: TextMatch) => TestView[] | Oui | — |
queryByText | (text: TextMatch) => TestView | null | Oui | — |
getByRole | (role: string, options?: RoleOptions) => TestView | Oui | The one view with role (and name, when given); throws when none or several have it. |
getAllByRole | (role: string, options?: RoleOptions) => TestView[] | Oui | — |
queryByRole | (role: string, options?: RoleOptions) => TestView | null | Oui | — |
getByText — signatures de méthode
Signatures
(text: TextMatch): TestViewParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
text | TextMatch | Oui | — |
Retourne
TestView
getAllByText — signatures de méthode
Signatures
(text: TextMatch): TestView[]Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
text | TextMatch | Oui | — |
Retourne
TestView[]
queryByText — signatures de méthode
Signatures
(text: TextMatch): TestView | nullParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
text | TextMatch | Oui | — |
Retourne
TestView
getByRole — signatures de méthode
Signatures
(role: string, options?: RoleOptions): TestViewParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
role | string | Oui | — |
options | RoleOptions | Non | — |
Retourne
TestView
getAllByRole — signatures de méthode
Signatures
(role: string, options?: RoleOptions): TestView[]Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
role | string | Oui | — |
options | RoleOptions | Non | — |
Retourne
TestView[]
queryByRole — signatures de méthode
Signatures
(role: string, options?: RoleOptions): TestView | nullParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
role | string | Oui | — |
options | RoleOptions | Non | — |
Retourne
TestView
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.