diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 30934211c..e6a8c4a08 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -47,8 +47,3 @@ jobs: run: yarn playwright install --with-deps - name: Vitest run: yarn ci:test - - name: Commit and Push changes - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "chore: update vitest screenshots [skip ci]" - file_pattern: "**/__screenshots__/**/*.png" diff --git a/AGENTS.md b/AGENTS.md index eef55bc62..c7024c1b4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,6 +52,7 @@ __tests__/ → Vitest browser-mode tests (Playwright) - `.res` files must always be capitalized (PascalCase), matching ReScript module conventions. - Use the pipe-first operator (`->`) for chaining, which is idiomatic ReScript. - Resolve all warnings and treat them as errors. The project has `"error": "+8"` in `rescript.json`. +- Never directly edit an `.jsx` files, you must edit the corresponding `.res` file. The `.jsx` files are generated by the ReScript compiler and will be overwritten on the next compile. ## ReScript Rules @@ -178,8 +179,10 @@ let default: unit => React.element }) ``` -- Components requiring React Router context must be wrapped in ``. -- Run tests with `yarn vitest`. +- Components requiring React Router context must be wrapped in ``. +- Do not use `` in tests. +- Run tests with `yarn vitest --browser.headless --run`. +- Do not update snapshots without asking for confirmation. ## MDX Content diff --git a/README.md b/README.md index 692d71a94..5cc3edbbe 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,27 @@ yarn dev ## Run Tests +### Unit Tests (Vitest) + +We use [Vitest](https://vitest.dev/) with browser mode (Playwright) for component-level unit tests. Test files live in `__tests__/` and are written in ReScript. + +```sh +# Run tests in watch mode (headed browser) +yarn vitest + +# Run tests once in headless mode (same as CI) +yarn ci:test +``` + +**Updating screenshots:** Screenshot baselines should only be updated in headless mode so they match CI and stay consistent across devices. Use the dedicated command: + +```sh +yarn vitest:update +``` + +This runs the full suite headlessly with the `--update` flag, regenerating any screenshot baselines that have changed. Commit the updated `.png` files alongside your code changes. +Please be selective in pushing up changes to screenshots and only update files that you have added or expected to change. Pushing up all changes can make it hard to review PRs with small image differences based on different devices or environments that wouldn't trigger failures in CI. + ### Markdown Codeblock Tests We check the validity of our code examples marked with: diff --git a/__tests__/MarkdownComponents_.test.res b/__tests__/MarkdownComponents_.test.res index 2d7a21efd..62ffc75c1 100644 --- a/__tests__/MarkdownComponents_.test.res +++ b/__tests__/MarkdownComponents_.test.res @@ -203,12 +203,14 @@ test("renders Image with caption", async () => { let screen = await render(
, ) - let caption = await screen->getByText("The ReScript logo") + let caption = await screen->getByText("A sample image caption") await element(caption)->toBeVisible let wrapper = await screen->getByTestId("image-wrapper") @@ -226,9 +228,6 @@ test("renders Video with caption", async () => { let caption = await screen->getByText("A sample video") await element(caption)->toBeVisible - - let wrapper = await screen->getByTestId("video-wrapper") - await element(wrapper)->toMatchScreenshot("markdown-video") }) test("renders horizontal rule", async () => { diff --git a/__tests__/NavbarSecondary_.test.res b/__tests__/NavbarSecondary_.test.res index 4746c83ca..796b30a99 100644 --- a/__tests__/NavbarSecondary_.test.res +++ b/__tests__/NavbarSecondary_.test.res @@ -5,9 +5,9 @@ test("desktop secondary navbar shows all doc section links", async () => { await viewport(1440, 500) let screen = await render( - + - , +
, ) let navbar = await screen->getByTestId("navbar-secondary") @@ -24,9 +24,9 @@ test("mobile secondary navbar shows all links", async () => { await viewport(600, 500) let screen = await render( - + - , + , ) let navbar = await screen->getByTestId("navbar-secondary") diff --git a/__tests__/__screenshots__/ApiLayout_.test.jsx/desktop-API-layout-shows-sidebar-categories-and-version-select-1.png b/__tests__/__screenshots__/ApiLayout_.test.jsx/desktop-API-layout-shows-sidebar-categories-and-version-select-1.png deleted file mode 100644 index b751321f8..000000000 Binary files a/__tests__/__screenshots__/ApiLayout_.test.jsx/desktop-API-layout-shows-sidebar-categories-and-version-select-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/ApiLayout_.test.jsx/mobile-API-layout-hides-sidebar-1.png b/__tests__/__screenshots__/ApiLayout_.test.jsx/mobile-API-layout-hides-sidebar-1.png deleted file mode 100644 index 80c3ddc0c..000000000 Binary files a/__tests__/__screenshots__/ApiLayout_.test.jsx/mobile-API-layout-hides-sidebar-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/ApiLayout_.test.jsx/old-docs-warning-shows-version-info-1.png b/__tests__/__screenshots__/ApiLayout_.test.jsx/old-docs-warning-shows-version-info-1.png deleted file mode 100644 index f993aad86..000000000 Binary files a/__tests__/__screenshots__/ApiLayout_.test.jsx/old-docs-warning-shows-version-info-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/desktop-API-overview-shows-all-category-items-1.png b/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/desktop-API-overview-shows-all-category-items-1.png deleted file mode 100644 index e83429f07..000000000 Binary files a/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/desktop-API-overview-shows-all-category-items-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/desktop-API-overview-shows-sidebar-categories-and-content-1.png b/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/desktop-API-overview-shows-sidebar-categories-and-content-1.png deleted file mode 100644 index bd9d90404..000000000 Binary files a/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/desktop-API-overview-shows-sidebar-categories-and-content-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/mobile-API-overview-hides-sidebar-1.png b/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/mobile-API-overview-hides-sidebar-1.png deleted file mode 100644 index 3f1b3f67b..000000000 Binary files a/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/mobile-API-overview-hides-sidebar-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/tablet-API-overview-1.png b/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/tablet-API-overview-1.png deleted file mode 100644 index 72019c22f..000000000 Binary files a/__tests__/__screenshots__/ApiOverviewLayout_.test.jsx/tablet-API-overview-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Banner_.test.jsx/mobile-banner-1.png b/__tests__/__screenshots__/Banner_.test.jsx/mobile-banner-1.png deleted file mode 100644 index 70886689f..000000000 Binary files a/__tests__/__screenshots__/Banner_.test.jsx/mobile-banner-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Banner_.test.jsx/renders-banner-with-content-1.png b/__tests__/__screenshots__/Banner_.test.jsx/renders-banner-with-content-1.png deleted file mode 100644 index ac79539d8..000000000 Binary files a/__tests__/__screenshots__/Banner_.test.jsx/renders-banner-with-content-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-archived-blog-article-shows-warning-banner-1.png b/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-archived-blog-article-shows-warning-banner-1.png deleted file mode 100644 index 22cb38495..000000000 Binary files a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-archived-blog-article-shows-warning-banner-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-renders-header--author--date--and-body-1.png b/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-renders-header--author--date--and-body-1.png deleted file mode 100644 index 4eda750d1..000000000 Binary files a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-renders-header--author--date--and-body-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-with-article-image-shows-image-1.png b/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-with-article-image-shows-image-1.png deleted file mode 100644 index 7af51cf47..000000000 Binary files a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-with-article-image-shows-image-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-with-co-authors-shows-all-authors-1.png b/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-with-co-authors-shows-all-authors-1.png deleted file mode 100644 index 185153fcb..000000000 Binary files a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-with-co-authors-shows-all-authors-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-without-description-1.png b/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-without-description-1.png deleted file mode 100644 index 4c2cc165d..000000000 Binary files a/__tests__/__screenshots__/BlogArticle_.test.jsx/desktop-blog-article-without-description-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/BlogArticle_.test.jsx/mobile-blog-article-1.png b/__tests__/__screenshots__/BlogArticle_.test.jsx/mobile-blog-article-1.png deleted file mode 100644 index 5912562dd..000000000 Binary files a/__tests__/__screenshots__/BlogArticle_.test.jsx/mobile-blog-article-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Blog_.test.jsx/desktop-blog-shows-archived-posts-1.png b/__tests__/__screenshots__/Blog_.test.jsx/desktop-blog-shows-archived-posts-1.png deleted file mode 100644 index 1e1455afe..000000000 Binary files a/__tests__/__screenshots__/Blog_.test.jsx/desktop-blog-shows-archived-posts-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Blog_.test.jsx/desktop-blog-with-single-post-1.png b/__tests__/__screenshots__/Blog_.test.jsx/desktop-blog-with-single-post-1.png deleted file mode 100644 index c0fe2ebc1..000000000 Binary files a/__tests__/__screenshots__/Blog_.test.jsx/desktop-blog-with-single-post-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Button_.test.jsx/renders-PrimaryBlue-button-1.png b/__tests__/__screenshots__/Button_.test.jsx/renders-PrimaryBlue-button-1.png deleted file mode 100644 index f96acbe35..000000000 Binary files a/__tests__/__screenshots__/Button_.test.jsx/renders-PrimaryBlue-button-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Button_.test.jsx/renders-PrimaryRed-button-1.png b/__tests__/__screenshots__/Button_.test.jsx/renders-PrimaryRed-button-1.png deleted file mode 100644 index 23ce58ce2..000000000 Binary files a/__tests__/__screenshots__/Button_.test.jsx/renders-PrimaryRed-button-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Button_.test.jsx/renders-SecondaryRed-button-1.png b/__tests__/__screenshots__/Button_.test.jsx/renders-SecondaryRed-button-1.png deleted file mode 100644 index f022fb79b..000000000 Binary files a/__tests__/__screenshots__/Button_.test.jsx/renders-SecondaryRed-button-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Button_.test.jsx/renders-Small-button-1.png b/__tests__/__screenshots__/Button_.test.jsx/renders-Small-button-1.png deleted file mode 100644 index 370ea8fff..000000000 Binary files a/__tests__/__screenshots__/Button_.test.jsx/renders-Small-button-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-with-highlighted-lines-1.png b/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-with-highlighted-lines-1.png deleted file mode 100644 index d9ac8de5d..000000000 Binary files a/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-with-highlighted-lines-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-with-language-label-1.png b/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-with-language-label-1.png deleted file mode 100644 index 7a34b7c9c..000000000 Binary files a/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-with-language-label-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-without-label-when-showLabel-is-false-1.png b/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-without-label-when-showLabel-is-false-1.png deleted file mode 100644 index 52833d29e..000000000 Binary files a/__tests__/__screenshots__/CodeExample_.test.jsx/renders-code-block-without-label-when-showLabel-is-false-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CodeExample_.test.jsx/renders-toggle-with-multiple-tabs-1.png b/__tests__/__screenshots__/CodeExample_.test.jsx/renders-toggle-with-multiple-tabs-1.png deleted file mode 100644 index c53aad15f..000000000 Binary files a/__tests__/__screenshots__/CodeExample_.test.jsx/renders-toggle-with-multiple-tabs-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CodeExample_.test.jsx/toggle-switches-between-tabs-on-click-1.png b/__tests__/__screenshots__/CodeExample_.test.jsx/toggle-switches-between-tabs-on-click-1.png deleted file mode 100644 index 3d0be472f..000000000 Binary files a/__tests__/__screenshots__/CodeExample_.test.jsx/toggle-switches-between-tabs-on-click-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CommunityLayout_.test.jsx/desktop-community-layout-shows-sidebar-and-content-1.png b/__tests__/__screenshots__/CommunityLayout_.test.jsx/desktop-community-layout-shows-sidebar-and-content-1.png deleted file mode 100644 index c400e4c93..000000000 Binary files a/__tests__/__screenshots__/CommunityLayout_.test.jsx/desktop-community-layout-shows-sidebar-and-content-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CommunityLayout_.test.jsx/desktop-community-layout-with-multiple-categories-1.png b/__tests__/__screenshots__/CommunityLayout_.test.jsx/desktop-community-layout-with-multiple-categories-1.png deleted file mode 100644 index 404ed6794..000000000 Binary files a/__tests__/__screenshots__/CommunityLayout_.test.jsx/desktop-community-layout-with-multiple-categories-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CommunityLayout_.test.jsx/mobile-community-layout-hides-sidebar-1.png b/__tests__/__screenshots__/CommunityLayout_.test.jsx/mobile-community-layout-hides-sidebar-1.png deleted file mode 100644 index 462bb857f..000000000 Binary files a/__tests__/__screenshots__/CommunityLayout_.test.jsx/mobile-community-layout-hides-sidebar-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/CommunityLayout_.test.jsx/tablet-community-layout-1.png b/__tests__/__screenshots__/CommunityLayout_.test.jsx/tablet-community-layout-1.png deleted file mode 100644 index aebf5cda8..000000000 Binary files a/__tests__/__screenshots__/CommunityLayout_.test.jsx/tablet-community-layout-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-highlights-active-nav-item-1.png b/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-highlights-active-nav-item-1.png deleted file mode 100644 index e5b21d679..000000000 Binary files a/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-highlights-active-nav-item-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-pagination--prev-next--1.png b/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-pagination--prev-next--1.png deleted file mode 100644 index 8515a1585..000000000 Binary files a/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-pagination--prev-next--1.png and /dev/null differ diff --git a/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-sidebar-with-categories-1.png b/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-sidebar-with-categories-1.png deleted file mode 100644 index 1fe3ddeb5..000000000 Binary files a/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-sidebar-with-categories-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-table-of-contents-entries-1.png b/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-table-of-contents-entries-1.png deleted file mode 100644 index 1fe3ddeb5..000000000 Binary files a/__tests__/__screenshots__/DocsLayout_.test.jsx/desktop-docs-layout-shows-table-of-contents-entries-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/DocsLayout_.test.jsx/mobile-docs-layout-hides-sidebar-by-default-1.png b/__tests__/__screenshots__/DocsLayout_.test.jsx/mobile-docs-layout-hides-sidebar-by-default-1.png deleted file mode 100644 index fa7845427..000000000 Binary files a/__tests__/__screenshots__/DocsLayout_.test.jsx/mobile-docs-layout-hides-sidebar-by-default-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/DocsOverview_.test.jsx/desktop-docs-overview-shows-all-section-cards-1.png b/__tests__/__screenshots__/DocsOverview_.test.jsx/desktop-docs-overview-shows-all-section-cards-1.png deleted file mode 100644 index a6394633f..000000000 Binary files a/__tests__/__screenshots__/DocsOverview_.test.jsx/desktop-docs-overview-shows-all-section-cards-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/DocsOverview_.test.jsx/desktop-docs-overview-shows-ecosystem-links-1.png b/__tests__/__screenshots__/DocsOverview_.test.jsx/desktop-docs-overview-shows-ecosystem-links-1.png deleted file mode 100644 index a6394633f..000000000 Binary files a/__tests__/__screenshots__/DocsOverview_.test.jsx/desktop-docs-overview-shows-ecosystem-links-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/DocsOverview_.test.jsx/mobile-docs-overview-1.png b/__tests__/__screenshots__/DocsOverview_.test.jsx/mobile-docs-overview-1.png deleted file mode 100644 index bf6897b24..000000000 Binary files a/__tests__/__screenshots__/DocsOverview_.test.jsx/mobile-docs-overview-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Footer_.test.jsx/desktop-footer-shows-all-sections-and-links-1.png b/__tests__/__screenshots__/Footer_.test.jsx/desktop-footer-shows-all-sections-and-links-1.png deleted file mode 100644 index 110fcffb2..000000000 Binary files a/__tests__/__screenshots__/Footer_.test.jsx/desktop-footer-shows-all-sections-and-links-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Footer_.test.jsx/mobile-footer-stacks-sections-vertically-1.png b/__tests__/__screenshots__/Footer_.test.jsx/mobile-footer-stacks-sections-vertically-1.png deleted file mode 100644 index 57e8570d1..000000000 Binary files a/__tests__/__screenshots__/Footer_.test.jsx/mobile-footer-stacks-sections-vertically-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MainLayout_.test.jsx/desktop-main-layout-renders-children-and-footer-1.png b/__tests__/__screenshots__/MainLayout_.test.jsx/desktop-main-layout-renders-children-and-footer-1.png deleted file mode 100644 index 64ce5a766..000000000 Binary files a/__tests__/__screenshots__/MainLayout_.test.jsx/desktop-main-layout-renders-children-and-footer-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MainLayout_.test.jsx/mobile-main-layout-1.png b/__tests__/__screenshots__/MainLayout_.test.jsx/mobile-main-layout-1.png deleted file mode 100644 index 6d5674b79..000000000 Binary files a/__tests__/__screenshots__/MainLayout_.test.jsx/mobile-main-layout-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/markdown-image-chromium-linux.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/markdown-image-chromium-linux.png index cea55eff3..6d361a284 100644 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/markdown-image-chromium-linux.png and b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/markdown-image-chromium-linux.png differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/markdown-video-chromium-linux.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/markdown-video-chromium-linux.png deleted file mode 100644 index 067090d24..000000000 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/markdown-video-chromium-linux.png and /dev/null differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Anchor-with-link-icon-1.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Anchor-with-link-icon-1.png deleted file mode 100644 index fc4b67bdf..000000000 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Anchor-with-link-icon-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Cite-without-author-1.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Cite-without-author-1.png deleted file mode 100644 index 924936093..000000000 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Cite-without-author-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Image-with-small-size-1.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Image-with-small-size-1.png deleted file mode 100644 index 7b4b2a8fc..000000000 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Image-with-small-size-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Strong-text-1.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Strong-text-1.png deleted file mode 100644 index 964b64ac3..000000000 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-Strong-text-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-inline-code-1.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-inline-code-1.png deleted file mode 100644 index 574d95c4e..000000000 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-inline-code-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-lists-1.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-lists-1.png deleted file mode 100644 index a59fef67a..000000000 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-lists-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-nested-list--ul-inside-li--1.png b/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-nested-list--ul-inside-li--1.png deleted file mode 100644 index 4f4afe78f..000000000 Binary files a/__tests__/__screenshots__/MarkdownComponents_.test.jsx/renders-nested-list--ul-inside-li--1.png and /dev/null differ diff --git a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/desktop-navbar-secondary-chromium-linux.png b/__tests__/__screenshots__/NavbarSecondary_.test.jsx/desktop-navbar-secondary-chromium-linux.png index bc51442ee..ceeb81806 100644 Binary files a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/desktop-navbar-secondary-chromium-linux.png and b/__tests__/__screenshots__/NavbarSecondary_.test.jsx/desktop-navbar-secondary-chromium-linux.png differ diff --git a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/desktop-secondary-navbar-shows-all-doc-section-links-1.png b/__tests__/__screenshots__/NavbarSecondary_.test.jsx/desktop-secondary-navbar-shows-all-doc-section-links-1.png deleted file mode 100644 index 68e650f4f..000000000 Binary files a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/desktop-secondary-navbar-shows-all-doc-section-links-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/mobile-navbar-secondary-chromium-linux.png b/__tests__/__screenshots__/NavbarSecondary_.test.jsx/mobile-navbar-secondary-chromium-linux.png index 5ba05892c..870cc995f 100644 Binary files a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/mobile-navbar-secondary-chromium-linux.png and b/__tests__/__screenshots__/NavbarSecondary_.test.jsx/mobile-navbar-secondary-chromium-linux.png differ diff --git a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/mobile-secondary-navbar-shows-all-links-1.png b/__tests__/__screenshots__/NavbarSecondary_.test.jsx/mobile-secondary-navbar-shows-all-links-1.png deleted file mode 100644 index b68ce07da..000000000 Binary files a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/mobile-secondary-navbar-shows-all-links-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/secondary-navbar-highlights-active-section-1.png b/__tests__/__screenshots__/NavbarSecondary_.test.jsx/secondary-navbar-highlights-active-section-1.png deleted file mode 100644 index 89bc240df..000000000 Binary files a/__tests__/__screenshots__/NavbarSecondary_.test.jsx/secondary-navbar-highlights-active-section-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SearchBox_.test.jsx/renders-with-a-value-1.png b/__tests__/__screenshots__/SearchBox_.test.jsx/renders-with-a-value-1.png deleted file mode 100644 index 210666bc7..000000000 Binary files a/__tests__/__screenshots__/SearchBox_.test.jsx/renders-with-a-value-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SearchBox_.test.jsx/renders-with-placeholder-text-1.png b/__tests__/__screenshots__/SearchBox_.test.jsx/renders-with-placeholder-text-1.png deleted file mode 100644 index 345e0e81e..000000000 Binary files a/__tests__/__screenshots__/SearchBox_.test.jsx/renders-with-placeholder-text-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SidebarLayout_.test.jsx/breadcrumbs-render-path-segments-1.png b/__tests__/__screenshots__/SidebarLayout_.test.jsx/breadcrumbs-render-path-segments-1.png deleted file mode 100644 index 6bbd23878..000000000 Binary files a/__tests__/__screenshots__/SidebarLayout_.test.jsx/breadcrumbs-render-path-segments-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SidebarLayout_.test.jsx/breadcrumbs-with-deep-path-1.png b/__tests__/__screenshots__/SidebarLayout_.test.jsx/breadcrumbs-with-deep-path-1.png deleted file mode 100644 index a3e7c46aa..000000000 Binary files a/__tests__/__screenshots__/SidebarLayout_.test.jsx/breadcrumbs-with-deep-path-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-highlights-active-item-1.png b/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-highlights-active-item-1.png deleted file mode 100644 index b5d9f7416..000000000 Binary files a/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-highlights-active-item-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-renders-title-and-nav-items-1.png b/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-renders-title-and-nav-items-1.png deleted file mode 100644 index 76d010528..000000000 Binary files a/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-renders-title-and-nav-items-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-with-active-TOC-renders-entries-1.png b/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-with-active-TOC-renders-entries-1.png deleted file mode 100644 index 2ac0bb615..000000000 Binary files a/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-with-active-TOC-renders-entries-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-with-many-items-1.png b/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-with-many-items-1.png deleted file mode 100644 index 7999cec54..000000000 Binary files a/__tests__/__screenshots__/SidebarLayout_.test.jsx/sidebar-category-with-many-items-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/deprecated-items-show-with-line-through-styling-1.png b/__tests__/__screenshots__/SyntaxLookup_.test.jsx/deprecated-items-show-with-line-through-styling-1.png deleted file mode 100644 index 5cf8af1c0..000000000 Binary files a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/deprecated-items-show-with-line-through-styling-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/desktop-syntax-lookup-renders-categories-and-tags-1.png b/__tests__/__screenshots__/SyntaxLookup_.test.jsx/desktop-syntax-lookup-renders-categories-and-tags-1.png deleted file mode 100644 index 5cf8af1c0..000000000 Binary files a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/desktop-syntax-lookup-renders-categories-and-tags-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/desktop-syntax-lookup-with-active-item-shows-detail-box-1.png b/__tests__/__screenshots__/SyntaxLookup_.test.jsx/desktop-syntax-lookup-with-active-item-shows-detail-box-1.png deleted file mode 100644 index 049ff22ce..000000000 Binary files a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/desktop-syntax-lookup-with-active-item-shows-detail-box-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/mobile-syntax-lookup-1.png b/__tests__/__screenshots__/SyntaxLookup_.test.jsx/mobile-syntax-lookup-1.png deleted file mode 100644 index d5c7ce17a..000000000 Binary files a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/mobile-syntax-lookup-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/mobile-syntax-lookup-with-active-item-1.png b/__tests__/__screenshots__/SyntaxLookup_.test.jsx/mobile-syntax-lookup-with-active-item-1.png deleted file mode 100644 index 8a6257e68..000000000 Binary files a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/mobile-syntax-lookup-with-active-item-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/syntax-lookup-detail-box-shows-summary-1.png b/__tests__/__screenshots__/SyntaxLookup_.test.jsx/syntax-lookup-detail-box-shows-summary-1.png deleted file mode 100644 index 0642aa1fd..000000000 Binary files a/__tests__/__screenshots__/SyntaxLookup_.test.jsx/syntax-lookup-detail-box-shows-summary-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Tag_.test.jsx/renders-multiple-tags-side-by-side-1.png b/__tests__/__screenshots__/Tag_.test.jsx/renders-multiple-tags-side-by-side-1.png deleted file mode 100644 index 17f02a83b..000000000 Binary files a/__tests__/__screenshots__/Tag_.test.jsx/renders-multiple-tags-side-by-side-1.png and /dev/null differ diff --git a/__tests__/__screenshots__/Tag_.test.jsx/renders-subtle-tag-with-text-1.png b/__tests__/__screenshots__/Tag_.test.jsx/renders-subtle-tag-with-text-1.png deleted file mode 100644 index a052ecada..000000000 Binary files a/__tests__/__screenshots__/Tag_.test.jsx/renders-subtle-tag-with-text-1.png and /dev/null differ diff --git a/package.json b/package.json index b232590b1..fc082b108 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build:vite": "react-router build", "build": "yarn build:res && yarn build:scripts && yarn build:update-index && yarn build:vite", "ci:format": "prettier . --check --experimental-cli", - "ci:test": "yarn vitest --run --browser.headless --update", + "ci:test": "yarn vitest --run --browser.headless", "clean:res": "rescript clean", "convert-images": "auto-convert-images", "dev:res": "rescript watch", @@ -30,7 +30,8 @@ "preview": "yarn build && static-server build/client", "reanalyze": "rescript-tools reanalyze -all-cmt .", "test": "node scripts/test-examples.mjs && node scripts/test-hrefs.mjs", - "vitest": "vitest" + "vitest": "vitest", + "vitest:update": "vitest --run --browser.headless --update" }, "dependencies": { "@babel/generator": "^7.24.7", diff --git a/styles/test-overrides.css b/styles/test-overrides.css new file mode 100644 index 000000000..b4631ed3b --- /dev/null +++ b/styles/test-overrides.css @@ -0,0 +1,20 @@ +/* + * Test overrides for consistent screenshots. + * This file is only imported in vitest.setup.mjs. + */ + +/* Disable all CSS animations and transitions */ +*, +*::before, +*::after { + animation-duration: 0s !important; + animation-delay: 0s !important; + transition-duration: 0s !important; + transition-delay: 0s !important; +} + +/* Force overlay scrollbars so scrollbar width is 0 in both headless and headed mode */ +* { + scrollbar-width: none !important; + scrollbar-gutter: auto !important; +} diff --git a/vitest.config.mjs b/vitest.config.mjs index 49417630f..c21428506 100644 --- a/vitest.config.mjs +++ b/vitest.config.mjs @@ -10,7 +10,12 @@ export default defineConfig({ setupFiles: ["./vitest.setup.mjs"], browser: { enabled: true, - provider: playwright(), + provider: playwright({ + contextOptions: { + deviceScaleFactor: 1, + }, + }), + ui: false, // https://vitest.dev/config/browser/playwright instances: [ { @@ -18,6 +23,17 @@ export default defineConfig({ viewport: { width: 1440, height: 900 }, }, ], + expect: { + toMatchScreenshot: { + screenshotOptions: { + scale: "css", + }, + comparatorOptions: { + threshold: 0.2, + allowedMismatchedPixelRatio: 0.05, + }, + }, + }, }, }, }); diff --git a/vitest.setup.mjs b/vitest.setup.mjs index 6d48aafc1..3ba70e746 100644 --- a/vitest.setup.mjs +++ b/vitest.setup.mjs @@ -1,2 +1,3 @@ import "./styles/main.css"; import "./styles/utils.css"; +import "./styles/test-overrides.css";