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

[改善] テストを追加 #79

Closed
wants to merge 3 commits into from
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
4 changes: 4 additions & 0 deletions docs/sample/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
const urlParams = new URLSearchParams(window.location.search);
const video = Number(urlParams.get("video") || 0);
const time = Number(urlParams.get("time") || 0);
const canvasWidth = Number(urlParams.get("width") || 1920);
const canvasHeight = Number(urlParams.get("height") || 1080);
canvasElement.width = canvasWidth;
canvasElement.height = canvasHeight;
const req = await fetch(`./commentdata/${video}.json`);
const res = await req.json();
const nico = new NiconiComments(canvasElement, res, {
Expand Down
15 changes: 13 additions & 2 deletions src/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ test("22(ヨワイボクラハウタウ)", async ({ page }) => {
});

const compare = async (page: Page, video: number, time: number) => {
await _compare(page, video, time);
await _compare(page, video, time, 1280, 720);
};

const _compare = async (
page: Page,
video: number,
time: number,
width = 1920,
height = 1080,
) => {
await page.goto(
`http://localhost:8080/docs/sample/test.html?time=${time}&video=${video}`,
`http://localhost:8080/docs/sample/test.html?time=${time}&video=${video}&width=${width}&height=${height}`,
);
await Promise.all([
page.waitForSelector("div#loaded", { state: "attached" }),
Expand All @@ -45,6 +56,6 @@ const compare = async (page: Page, video: number, time: number) => {
await expect(page).toHaveScreenshot(`${video}-${time}.png`);
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(
`${video}-${time}.png`,
{ threshold: 0.075 },
{ threshold: 0.1 },
);
};
Loading