-
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.
- Loading branch information
askirmas
committed
Aug 12, 2020
1 parent
00e4a26
commit f31cd2c
Showing
8 changed files
with
1,171 additions
and
505 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {toMatchImageSnapshot} from "jest-image-snapshot" | ||
import puppeteer, {Browser, Page} from "puppeteer" | ||
|
||
expect.extend({toMatchImageSnapshot}) | ||
|
||
const fileName = 'Andrii_Kirmas' | ||
, cwd = process.cwd() | ||
|
||
let browser: Browser, page :Page | ||
|
||
beforeAll(async () => { | ||
browser = await puppeteer.launch({ | ||
"args": ["--allow-file-access-from-files", "--enable-local-file-accesses "] | ||
}) | ||
page = await browser.newPage() | ||
}) | ||
|
||
it("web", async () => { | ||
await page.goto(`file://${cwd}/index.html`, { | ||
"waitUntil": "networkidle2" | ||
}) | ||
await page.setViewport({ width: 1800, height: 980 }) | ||
|
||
const screenshot = await page.screenshot({ | ||
"fullPage": true, | ||
"type": "png" | ||
}) | ||
|
||
expect(screenshot).toMatchImageSnapshot( { | ||
"customSnapshotIdentifier": `${fileName}-web` | ||
}) | ||
|
||
if (process.env.npm_config_pdf_gen) | ||
await page.pdf({ | ||
"path": `${cwd}/${fileName}.pdf`, | ||
"format": "A4", | ||
"printBackground": true, | ||
"pageRanges": '1', | ||
"scale": 0.70 | ||
}) | ||
}) | ||
|
||
it.skip("pdf https://bugs.chromium.org/p/chromium/issues/detail?id=761295", async () => { | ||
|
||
await page.goto(`file://${cwd}/${fileName}.pdf`, { | ||
"waitUntil": "networkidle2" | ||
}) | ||
|
||
const screenshot = await page.screenshot({ | ||
"fullPage": true, | ||
"type": "png" | ||
}) | ||
|
||
expect(screenshot).toMatchImageSnapshot( { | ||
"customSnapshotIdentifier": `${fileName}-pdf` | ||
}) | ||
}) | ||
|
||
|
||
afterAll(async () => await 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"preset": "ts-jest", | ||
"testEnvironment": "node" | ||
} |
Oops, something went wrong.