Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding test case for issue 210 #227

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions __tests__/diff-large-snapshot.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const puppeteer = require('puppeteer')
const { toMatchImageSnapshot } = require('../src/index')

let browser
let page

beforeAll(async () => {
// start Puppeteer with a custom configuration, see above the setup
browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
})
expect.extend({ toMatchImageSnapshot })
// load page
page = await browser.newPage()
await page.goto(`https://www.theverge.com/`, {waitUntil: 'load'});
// scroll to bottom and back up
await page.waitFor(1000)
await page.evaluate(() => {
window.scrollTo(0, Number.MAX_SAFE_INTEGER)
})
await page.waitFor(500)
await page.evaluate(() => {
window.scrollBy(0, 0)
})
await page.waitFor(500)
})

test(`Testing viewport: 1400`, async () => {
// set viewport
await page.setViewport({
width: 1400,
height: 900,
deviceScaleFactor: 1
})
// take full screen screenshot
let image = await page.screenshot({
path: `${__dirname}/__image_snapshots__/verge-1440.png`,
type: 'png',
fullPage: true
})
// compare screenshot
expect(image).toMatchImageSnapshot({
customDiffConfig: {
threshold: 0.01
},
customDiffDir: `${__dirname}/__image_snapshots__/`,
customSnapshotsDir: `${__dirname}/__custom_snapshots_dir__/`,
customSnapshotIdentifier: `verge-1440`,
noColors: true
})
}, 15000)

afterAll(async () => {
await browser.close()
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"mkdirp": "^0.5.1",
"pixelmatch": "^5.1.0",
"pngjs": "^3.4.0",
"puppeteer": "^5.2.1",
"rimraf": "^2.6.2"
},
"peerDependencies": {
Expand Down