From e820a042487d1efaec2ea2202d77c970af85d4b5 Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Fri, 26 Nov 2021 01:21:49 -0800 Subject: [PATCH] docs: add mention of text queries --- docs/api.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/api.md b/docs/api.md index 7de00a1..a389c17 100644 --- a/docs/api.md +++ b/docs/api.md @@ -17,6 +17,9 @@ Instead, the following API is what `CLI Testing Library` provides the following. - [`render` Options](#render-options) - [`cwd`](#cwd) - [`spawnOpts`](#spawnopts) +- [`render` Result](#render-result) + - [`...queries`](#queries) + - [ByText](#bytext) @@ -87,3 +90,37 @@ const {getByText} = render('script.ps1', { } }) ``` + +# `render` Result + +The `render` method returns an object that has a few properties: + +## `...queries` + +The most important feature of render is that the queries from [CLI Testing Library](https://github.com/crutchcorn/cli-testing-library) +are automatically returned with their first argument bound to the testInstance. + +See [Queries](./queries.md) to learn more about how to use these queries and the philosophy behind them. + +### ByText + +> getByText, queryByText, findByText + +```typescript +getByText( + // If you're using `screen`, then skip the container argument: + instance: TestInstance, + text: TextMatch, + options?: { + exact?: boolean = true, + trim?: boolean = false, + stripAnsi?: boolean = false, + collapseWhitespace?: boolean = false, + normalizer?: NormalizerFn, + suggest?: boolean, + }): TestInstance +``` + +Queries for test instance `stdout` results with the given text (and it also accepts a TextMatch). + +These options are all standard for text matching. To learn more, see our [Queries page](./queries.md). -- knotmirror 0.0.1