Skip to content

Commit

Permalink
Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Jan 14, 2024
1 parent 7941969 commit 3967526
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 5 deletions.
3 changes: 3 additions & 0 deletions e2e/collections/BlogPage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { BasePage } from "./BasePage.js"

export class BlogPage extends BasePage {
codeBlock = (header: string) =>
this.el(`h2:has-text("${header}") ~ .code-block`)

async goto(path = "") {
await this.frame.goto(`/blog${path}`)
}
Expand Down
Binary file added e2e/test/__snapshots__/blog.test.ts/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/test/__snapshots__/blog.test.ts/title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions e2e/test/blog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,37 @@ test.describe("Blog page", async () => {
})
})
})

test.describe("snapshots", () => {
test("post header", async ({ blogPage, page }) => {
await blogPage.goto("/efficient-prisma-pagination")
await expect(page.locator("article header")).toHaveScreenshot(
"header.png",
)
})

test("basic code block", async ({ blogPage }) => {
await blogPage.goto("/efficient-prisma-pagination")
const single = blogPage.codeBlock("Representing state in the URL").first()
const multi = blogPage.codeBlock("Previous/next links").last()
const lineNumbers = blogPage.codeBlock("The search query")

await expect(single).toHaveScreenshot("single-line.png")
await expect(multi).toHaveScreenshot("multi-line.png")
await expect(lineNumbers.nth(0)).toHaveScreenshot("line-numbers.png")
await expect(lineNumbers.nth(1)).toHaveScreenshot(
"line-numbers-highlight.png",
)
})

test("code block titles", async ({ blogPage }) => {
await blogPage.goto("/using-yarn-constraints")
const title = blogPage.codeBlock("Let’s see an example").first()
await expect(title).toHaveScreenshot("title.png")

await blogPage.goto("/automated-npm-publishing-using-github-actions")
const lineNumbers = blogPage.codeBlock("Basic publish action").first()
await expect(lineNumbers).toHaveScreenshot("title-line-numbers.png")
})
})
})
9 changes: 4 additions & 5 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { expect, PlaywrightTestConfig } from "@playwright/test"
import { defineConfig, expect } from "@playwright/test"
import axeMatchers from "expect-axe-playwright"
import { fileURLToPath } from "node:url"

expect.extend(axeMatchers)

const config: PlaywrightTestConfig = {
export default defineConfig({
forbidOnly: !!process.env.CI,
fullyParallel: true,
reporter: process.env.CI ? "dot" : "list",
retries: process.env.CI ? 2 : 0,
snapshotPathTemplate: "{testDir}/__snapshots__/{testFilePath}/{arg}{ext}",
testDir: fileURLToPath(new URL("./e2e/test", import.meta.url)),
use: {
axeOptions: {
Expand All @@ -27,6 +28,4 @@ const config: PlaywrightTestConfig = {
stdout: "ignore",
url: "http://127.0.0.1:3000",
},
}

export default config
})

0 comments on commit 3967526

Please sign in to comment.