From 8870aaee178d2b3b01aeb07a9ffb6339389b15be Mon Sep 17 00:00:00 2001 From: JoelEinbinder Date: Thu, 27 Jul 2017 11:44:18 -0700 Subject: [PATCH] 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 --- docs/api.md | 6 ++++-- test/test.js | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index e578b601..4aa0c70a 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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. diff --git a/test/test.js b/test/test.js index e674454a..372d5150 100644 --- a/test/test.js +++ b/test/test.js @@ -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);