Utilisation

Query the rendered screen.

tsx
// 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

NomTypeRequisDescription
getByText(text: TextMatch) => TestViewOuiThe one view showing text; throws when none or several do.
getAllByText(text: TextMatch) => TestView[]Oui—
queryByText(text: TextMatch) => TestView | nullOui—
getByRole(role: string, options?: RoleOptions) => TestViewOuiThe 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 | nullOui—
getByText — signatures de méthode

Signatures

ts
(text: TextMatch): TestView

Paramètres

NomTypeRequisDescription
textTextMatchOui—

Retourne

TestView

getAllByText — signatures de méthode

Signatures

ts
(text: TextMatch): TestView[]

Paramètres

NomTypeRequisDescription
textTextMatchOui—

Retourne

TestView[]

queryByText — signatures de méthode

Signatures

ts
(text: TextMatch): TestView | null

Paramètres

NomTypeRequisDescription
textTextMatchOui—

Retourne

TestView

getByRole — signatures de méthode

Signatures

ts
(role: string, options?: RoleOptions): TestView

Paramètres

NomTypeRequisDescription
rolestringOui—
optionsRoleOptionsNon—

Retourne

TestView

getAllByRole — signatures de méthode

Signatures

ts
(role: string, options?: RoleOptions): TestView[]

Paramètres

NomTypeRequisDescription
rolestringOui—
optionsRoleOptionsNon—

Retourne

TestView[]

queryByRole — signatures de méthode

Signatures

ts
(role: string, options?: RoleOptions): TestView | null

Paramètres

NomTypeRequisDescription
rolestringOui—
optionsRoleOptionsNon—

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.