forked from puppeteer/puppeteer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds some minimal tests for puppeteer's Page using Jasmine.
- Loading branch information
1 parent
62e6815
commit 6fc5466
Showing
3 changed files
with
55 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var Browser = require('../lib/Browser'); | ||
|
||
describe('Page', function() { | ||
var browser; | ||
var page; | ||
|
||
beforeAll(function() { | ||
browser = new Browser(); | ||
}); | ||
|
||
afterAll(function() { | ||
browser.close(); | ||
}); | ||
|
||
beforeEach(SX(async function() { | ||
page = await browser.newPage(); | ||
})); | ||
|
||
afterEach(function() { | ||
page.close(); | ||
}); | ||
|
||
it('Page.evaluate', SX(async function() { | ||
var result = await page.evaluate(() => 7 * 3); | ||
expect(result).toBe(21); | ||
})); | ||
|
||
it('Page.evaluateAsync', SX(async function() { | ||
var result = await page.evaluateAsync(() => Promise.resolve(8 * 7)); | ||
expect(result).toBe(56); | ||
})); | ||
}); | ||
|
||
// Since Jasmine doesn't like async functions, they should be wrapped | ||
// in a SX function. | ||
function SX(fun) { | ||
return done => Promise.resolve(fun()).then(done).catch(done.fail); | ||
} |