From a6a1c61d9339eeb164bc64f22805225e51e3a43a Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Thu, 22 Apr 2021 00:52:30 -0500 Subject: [PATCH] chore(readme): add note about matching outer element (#400) --- packages/expect-puppeteer/README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/expect-puppeteer/README.md b/packages/expect-puppeteer/README.md index db0b3c0e..8a7a073c 100644 --- a/packages/expect-puppeteer/README.md +++ b/packages/expect-puppeteer/README.md @@ -52,13 +52,31 @@ This API is designed for integration testing: // Does not work if button is not in page await page.click('button') -// Will try while 500ms to click on "button" +// Will try for 500ms to click on "button" await page.toClick('button') -// Will match a button with a "My button" text inside +// Will click the first button with a "My button" text inside await page.toClick('button', { text: 'My button' }) ``` +The first element to match will be selected + +**Example** + +```html +
+
some text
+
+``` + +```js +// Will match outer div +await expect(page).toMatch('div', { text: 'some text' }) + +// Will match inner div +await expect(page).toMatch('div.inner', { text: 'some text' }) +``` + ## API ##### Table of Contents