mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-25 06:49:23 +01:00
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
const puppeteer = require("puppeteer");
|
|
|
|
const BASE = process.env.BASE;
|
|
|
|
describe("home page", () => {
|
|
let browser;
|
|
|
|
beforeAll(async () => {
|
|
browser = await puppeteer.launch({
|
|
args: ["--no-sandbox", "--disable-setuid-sandbox"],
|
|
executablePath: process.env.CHROME_EXE_PATH || "",
|
|
defaultViewport: { width: 1920, height: 1200 },
|
|
});
|
|
});
|
|
|
|
it("renders full page on desktop", async () => {
|
|
const page = await browser.newPage();
|
|
await page.goto(BASE, {});
|
|
|
|
const image = await page.screenshot({ fullPage: true });
|
|
|
|
expect(image).toMatchImageSnapshot();
|
|
});
|
|
|
|
it("renders ipad viewport", async () => {
|
|
const page = await browser.newPage();
|
|
await page.goto(BASE, {});
|
|
await page.setViewport({ width: 1024, height: 768 });
|
|
const image = await page.screenshot();
|
|
|
|
expect(image).toMatchImageSnapshot();
|
|
});
|
|
|
|
it("renders iphone viewport", async () => {
|
|
const page = await browser.newPage();
|
|
await page.goto(BASE, {});
|
|
await page.setViewport({ width: 372, height: 812 });
|
|
const image = await page.screenshot();
|
|
|
|
expect(image).toMatchImageSnapshot();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await browser.close();
|
|
});
|
|
});
|