Skip to content

Commit 17b882d

Browse files
committed
add toHaveLocalStorageItem API Docs
1 parent 5550d9f commit 17b882d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/API.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,33 @@ await expect(browser).toHaveClipboardText('some clipboard text')
245245
await expect(browser).toHaveClipboardText(expect.stringContaining('clipboard text'))
246246
```
247247

248+
### toHaveLocalStorageItem
249+
250+
Checks if browser has a specific item in localStorage with an optional value.
251+
252+
##### Usage
253+
254+
```js
255+
await browser.url('https://webdriver.io/')
256+
// Check if localStorage item exists
257+
await expect(browser).toHaveLocalStorageItem('existingKey')
258+
259+
// Check localStorage item with exact value
260+
await expect(browser).toHaveLocalStorageItem('someLocalStorageKey', 'someLocalStorageValue')
261+
262+
// Check with case insensitive
263+
await expect(browser).toHaveLocalStorageItem('key', 'uppercase', { ignoreCase: true })
264+
265+
// Check with trim
266+
await expect(browser).toHaveLocalStorageItem('key', 'value', { trim: true })
267+
268+
// Check with containing
269+
await expect(browser).toHaveLocalStorageItem('key', 'long', { containing: true })
270+
271+
// Check with regex
272+
await expect(browser).toHaveLocalStorageItem('userId', /^user_\d+$/)
273+
```
274+
248275
## Element Matchers
249276

250277
### toBeDisplayed

0 commit comments

Comments
 (0)