Skip to content

Commit

Permalink
Docusaurus: lost pixel (#5797)
Browse files Browse the repository at this point in the history
* add visual regression testing with Lost Pixel

* update sidebars to remove duplicate routes

* edit page names before sending to lost pixel
  • Loading branch information
jharrell committed Apr 10, 2024
1 parent f726217 commit 1daee7f
Show file tree
Hide file tree
Showing 5 changed files with 1,097 additions and 220 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/lost-pixel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on: [push]

jobs:
build:
runs-on: ubuntu-latest
name: Lost Pixel

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18

- name: Install deps
run: npm install

- name: Build docs
run: npm run clean & npm run build

- name: Start docs
run: npm run serve &

- name: Generate sitemap
run: npx lost-pixel page-sitemap-gen http://172.17.0.1:3000/sitemap.xml "./lost-pixel-pages.json"

- name: Edit page names
run: sed -i -e 's/_/\//g' -e 's/prisma\.io//g' -re 's/(name.+)(\/)(\")/\1-\3/g' lost-pixel-pages.json

- name: Lost Pixel
uses: lost-pixel/[email protected]
env:
LOST_PIXEL_API_KEY: ${{ secrets.LOST_PIXEL_API_KEY }}
42 changes: 42 additions & 0 deletions lostpixel.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { CustomProjectConfig } from 'lost-pixel';

export const config: CustomProjectConfig = {
pageShots: {
pages: [],
pagesJsonUrl: './lost-pixel-pages.json',
baseUrl: 'http://172.17.0.1:3000',
},
lostPixelProjectId: 'clb5ek3mm1772001qqg7yban38',
apiKey: process.env.LOST_PIXEL_API_KEY,
compareConcurrency: 10,
shotConcurrency: 10,
threshold: 10,
beforeScreenshot: async (page) => {
await page.addStyleTag({
content: `iframe {
visibility: hidden;
}
/* do not show underline animation */
#toc-holder a {
background-size: 0 !important;
background-image: none !important;
}
/* skip image display within section */
section img {
visibility: hidden;
}
/* hide cookie banner */
#onetrust-consent-sdk {
display: none;
}
/* reset menu item alignment */
#sidebar-holder li a {
vertical-align: baseline;
}
`,
})
}
};
Loading

0 comments on commit 1daee7f

Please sign in to comment.