Skip to content

Conversation

NaamuKim
Copy link

What I do

Added tests with the toHaveLocalStorageItem function

Why this function is needed

before

const tokenExists = await browser.execute(() => {
    return localStorage.getItem('authToken') !== null
})
expect(tokenExists).toBe(true)

const tokenValue = await browser.execute(() => {
    return localStorage.getItem('authToken')
})
expect(tokenValue).toMatch(/^[A-Za-z0-9-_]+\./)

after

await expect(browser).toHaveLocalStorageItem('authToken')
await expect(browser).toHaveLocalStorageItem('authToken', /^[A-Za-z0-9-_]+\./)

If you need anything else, let me know and I'll get it implemented quickly.
If this API is okay, I'll also add a PR for Session storage.

@NaamuKim NaamuKim changed the title Feature/to have local storage item feat(expect-webdriverio): add toHaveLocalStorageItem matcher Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant