-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3 Replace waitForResource internals with native API, add WIP test fo…
…r Extensions
- Loading branch information
Showing
8 changed files
with
101 additions
and
81 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as puppeteer from 'puppeteer'; | ||
import Extensions from './Extensions'; | ||
|
||
jest.setTimeout(10000); | ||
|
||
describe('Extensions', () => { | ||
describe('waitForResource', () => { | ||
let browser; | ||
|
||
beforeAll(async () => { | ||
browser = await puppeteer.launch(); | ||
}); | ||
|
||
it('should respond with true if resource response is found', async () => { | ||
const page = await browser.newPage(); | ||
|
||
const extensions = new Extensions(page, 10000); | ||
const response = extensions.waitForResource('main'); | ||
|
||
await page.goto('https://www.gideonpyzer.com'); | ||
|
||
await response; | ||
expect(response).toBeTruthy(); | ||
}); | ||
|
||
it('should timeout when waiting for resource that will not be requested for', async () => { | ||
const page = await browser.newPage(); | ||
|
||
const extensions = new Extensions(page, 10000); | ||
const response = extensions.waitForResource('bla', 500); | ||
|
||
await page.goto('https://www.gideonpyzer.com'); | ||
|
||
try { | ||
await response; | ||
} catch (e) { | ||
expect(e.message).toBe( | ||
'Timeout exceeded while waiting for event' | ||
); | ||
} | ||
}); | ||
|
||
afterAll(async () => { | ||
browser.close(); | ||
}); | ||
}); | ||
}); |
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