-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: moving toMatchInShadow into toMatch
- Loading branch information
Showing
8 changed files
with
198 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 47 additions & 39 deletions
86
packages/expect-puppeteer/src/matchers/notToMatch.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,55 @@ | ||
import { setupPage } from './setupPage' | ||
|
||
describe('not.toMatch', () => { | ||
describe('not.toMatch1111', () => { | ||
beforeEach(async () => { | ||
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'])( | ||
'%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 } | ||
: {} | ||
|
||
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', () => { | ||
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') | ||
} | ||
}) | ||
}) | ||
}, | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.