-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved exception handling, tests, examples and documentation
- Loading branch information
Tobias
committed
Dec 15, 2017
1 parent
28e7f13
commit 7206cdd
Showing
13 changed files
with
344 additions
and
141 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const puppeteer = require('puppeteer'); | ||
const RequestInterceptor = require('puppeteer-request-spy').RequestInterceptor; | ||
const RequestSpy = require('puppeteer-request-spy').RequestSpy; | ||
const assert = require('assert'); | ||
|
||
let browser; | ||
|
||
before(async () => { | ||
browser = await puppeteer.launch({ | ||
headless: true | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
await browser.close(); | ||
}); | ||
|
||
describe('example-block', function () { | ||
|
||
this.timeout(30000); | ||
this.slow(20000); | ||
|
||
let requestInterceptor; | ||
let imagesSpy; | ||
|
||
before(() => { | ||
imagesSpy = new RequestSpy('images'); | ||
requestInterceptor = new RequestInterceptor( | ||
(testee, pattern) => testee.indexOf(pattern) > -1, | ||
console | ||
); | ||
|
||
requestInterceptor.addSpy(imagesSpy); | ||
}); | ||
|
||
describe('example-block', function () { | ||
it('example-test', async function () { | ||
let page = await browser.newPage(); | ||
|
||
page.on('request', requestInterceptor.intercept.bind(requestInterceptor)); | ||
|
||
await page.goto('https://www.example.org/', { | ||
waitUntil: 'networkidle0', | ||
timeout: 3000000 | ||
}); | ||
|
||
assert.ok(imagesSpy.hasMatch() && imagesSpy.getMatchCount() > 0); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.