Utilisation

Find text with a string or pattern.

tsx
// Find text with a string or pattern.
import { Text } from 'kuito';
import { assert, render, screen, test, type TextMatch } from 'kuito/tests';

// A string matches the whole text; a RegExp tests it.
const itemsLeft: TextMatch = /^\d+ items? left$/;

test('the footer counts what is left', async () => {
  await render(<Text>3 items left</Text>);

  assert.ok(screen.getByText(itemsLeft));
  assert.equal(screen.queryByText('3 items'), null);
});

Déclaration du type

ts
export type TextMatch = string | RegExp;

Type

ts
string | RegExp
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.