-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adding a new matcher for shadow DOM toMatch #463
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,43 +5,51 @@ describe('not.toMatch', () => { | |
await page.goto(`http://localhost:${process.env.TEST_SERVER_PORT}`) | ||
}) | ||
|
||
describe.each(['Page', 'Frame'])('%s', (pageType) => { | ||
let page | ||
setupPage(pageType, ({ currentPage }) => { | ||
page = currentPage | ||
}) | ||
it('should be ok if text is not in the page', async () => { | ||
await expect(page).not.toMatch('Nop!') | ||
}) | ||
|
||
it('should return an error if text is in the page', async () => { | ||
expect.assertions(3) | ||
|
||
try { | ||
await expect(page).not.toMatch('home') | ||
} catch (error) { | ||
expect(error.message).toMatch('Text found "home"') | ||
expect(error.message).toMatch('waiting for function failed') | ||
} | ||
}) | ||
}) | ||
describe.each(['Page', 'Frame', 'ShadowPage', 'ShadowFrame'])( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same test cases, just adding page types. |
||
'%s', | ||
(pageType) => { | ||
let page | ||
setupPage(pageType, ({ currentPage }) => { | ||
page = currentPage | ||
}) | ||
|
||
describe('ElementHandle', () => { | ||
it('should be ok if text is in the page', async () => { | ||
const dialogBtn = await page.$('#dialog-btn') | ||
await expect(dialogBtn).not.toMatch('Nop') | ||
}) | ||
|
||
it('should return an error if text is not in the page', async () => { | ||
expect.assertions(3) | ||
const dialogBtn = await page.$('#dialog-btn') | ||
|
||
try { | ||
await expect(dialogBtn).not.toMatch('Open dialog') | ||
} catch (error) { | ||
expect(error.message).toMatch('Text found "Open dialog"') | ||
expect(error.message).toMatch('waiting for function failed') | ||
} | ||
}) | ||
}) | ||
const options = ['ShadowPage', 'ShadowFrame'].includes(pageType) | ||
? { traverseShadowRoots: true } | ||
: {} | ||
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. run |
||
|
||
it('should be ok if text is not in the page', async () => { | ||
await expect(page).not.toMatch('Nop!', options) | ||
}) | ||
|
||
it('should return an error if text is in the page', async () => { | ||
expect.assertions(3) | ||
|
||
try { | ||
await expect(page).not.toMatch('home', options) | ||
} catch (error) { | ||
expect(error.message).toMatch('Text found "home"') | ||
expect(error.message).toMatch('waiting for function failed') | ||
} | ||
}) | ||
|
||
describe('ElementHandle', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved |
||
it('should be ok if text is in the page', async () => { | ||
const dialogBtn = await page.$('#dialog-btn') | ||
await expect(dialogBtn).not.toMatch('Nop', options) | ||
}) | ||
|
||
it('should return an error if text is not in the page', async () => { | ||
expect.assertions(3) | ||
const dialogBtn = await page.$('#dialog-btn') | ||
|
||
try { | ||
await expect(dialogBtn).not.toMatch('Open dialog', options) | ||
} catch (error) { | ||
expect(error.message).toMatch('Text found "Open dialog"') | ||
expect(error.message).toMatch('waiting for function failed') | ||
} | ||
}) | ||
}) | ||
}, | ||
) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get
textContent
from eithergetShadowTextContent
or node'stextContent
based ontraverseShadowRoots
option.