Disable and enable some tests based on whether chrome is headless (#154)

This patch:
- Runs dialog test in headful mode only
- Runs pdf test in headless mode only
- Improves on documentation to outline these shortcomings
This commit is contained in:
JoelEinbinder 2017-07-27 11:44:18 -07:00 committed by Andrey Lushnikov
parent 70f77c1981
commit 8870aaee17
2 changed files with 7 additions and 4 deletions

View File

@ -484,6 +484,8 @@ The `format` options are:
- `A4`: 8.27in x 11.7in
- `A5`: 5.83in x 8.27in
> **NOTE** Generating a pdf is currently only supported in Chrome headless.
#### page.plainText()
- returns: <[Promise]<[string]>> Returns page's inner text.
@ -584,7 +586,7 @@ browser.newPage().then(async page =>
- `isLandscape` <[boolean]> Specify if viewport is in the landscape mode. Defaults to `false`.
- returns: <[Promise]> Promise which resolves when the dimensions are updated.
Note: in certain cases, setting viewport will reload the page so that the `isMobile` or `hasTouch` options will be able to interfere in project loading.
> **NOTE** in certain cases, setting viewport will reload the page so that the `isMobile` or `hasTouch` options will be able to interfere in project loading.
The page's viewport size defines page's dimensions, observable from page via `window.innerWidth / window.innerHeight`. The viewport size defines a size of page
screenshot (unless a `fullPage` option is given).
@ -749,7 +751,7 @@ browser.newPage().then(async page => {
});
```
> NOTE: Chrome Headless currently has issues with managing javascript dialogs, see [issue 13](https://github.com/GoogleChrome/puppeteer/issues/13)
> **NOTE** Chrome Headless currently has issues with managing javascript dialogs, see [issue 13](https://github.com/GoogleChrome/puppeteer/issues/13)
#### dialog.accept([promptText])
- `promptText` <[string]> A text to enter in prompt. Does not cause any effects if the dialog's `type` is not prompt.

View File

@ -647,7 +647,7 @@ describe('Puppeteer', function() {
page.evaluate(() => alert('yo'));
});
// TODO Enable this when crbug.com/718235 is fixed.
xit('should allow accepting prompts', SX(async function(done) {
(headless ? xit : it)('should allow accepting prompts', SX(async function(done) {
page.on('dialog', dialog => {
expect(dialog.type).toBe('prompt');
expect(dialog.message()).toBe('question?');
@ -1209,7 +1209,8 @@ describe('Puppeteer', function() {
fs.unlinkSync(outputFile);
});
it('should print to pdf', SX(async function() {
// Printing to pdf is currently only supported in headless
(headless ? it : xit)('should print to pdf', SX(async function() {
await page.navigate(PREFIX + '/grid.html');
await page.pdf({path: outputFile});
expect(fs.readFileSync(outputFile).byteLength).toBeGreaterThan(0);