Skip to content

test(theme): Add robust Jest/TS support and tests for theme components #1145

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

sserrata
Copy link
Member

@sserrata sserrata commented May 9, 2025

  • Add tests for ArrayBrackets, SkeletonLoader, StatusCodes, and ApiLogo components
  • Mock Docusaurus and theme modules (@theme/ApiTabs, @theme/Details, etc.) via mocks and manual Jest config mappings
  • Add @ts-ignore to theme imports in StatusCodes to bypass TS2307 errors
  • Add custom type declarations for theme mocks (src/theme-modules.d.ts) and update tsconfig.json for global recognition
  • Update jest.config.js for explicit moduleNameMapper entries and jsdom environment
  • Add setupTests.d.ts for jest-dom matchers and global test types
  • Ensure all new and updated files are included for proper TypeScript and Jest operation

This enables reliable, isolated testing of theme components in docusaurus-theme-openapi-docs.

Description

Experimenting with using Windsurf to generate tests for theme components

Motivation and Context

Migrate tests to theme package to help with validation between changes

How Has This Been Tested?

yarn test packages/docusaurus-theme-openapi-docs/src/theme

- Add tests for ArrayBrackets, SkeletonLoader, StatusCodes, and ApiLogo components
- Mock Docusaurus and theme modules (@theme/ApiTabs, @theme/Details, etc.) via __mocks__ and manual Jest config mappings
- Add @ts-ignore to theme imports in StatusCodes to bypass TS2307 errors
- Add custom type declarations for theme mocks (src/theme-modules.d.ts) and update tsconfig.json for global recognition
- Update jest.config.js for explicit moduleNameMapper entries and jsdom environment
- Add setupTests.d.ts for jest-dom matchers and global test types
- Ensure all new and updated files are included for proper TypeScript and Jest operation

This enables reliable, isolated testing of theme components in docusaurus-theme-openapi-docs.
@sserrata sserrata self-assigned this May 9, 2025
Copy link

github-actions bot commented May 9, 2025

Size Change: 0 B

Total Size: 2.13 MB

ℹ️ View Unchanged
Filename Size
demo/.docusaurus/codeTranslations.json 2 B
demo/.docusaurus/docusaurus.config.mjs 14.3 kB
demo/.docusaurus/globalData.json 54.4 kB
demo/.docusaurus/i18n.json 267 B
demo/.docusaurus/registry.js 78.9 kB
demo/.docusaurus/routes.js 74.7 kB
demo/.docusaurus/routesChunkNames.json 30.8 kB
demo/.docusaurus/site-metadata.json 1.35 kB
demo/build/assets/css/styles.********.css 146 kB
demo/build/assets/js/main.********.js 707 kB
demo/build/assets/js/runtime~main.********.js 19.9 kB
demo/build/index.html 91.5 kB
demo/build/petstore/add-pet/index.html 28.1 kB
demo/build/petstore/create-user/index.html 22.2 kB
demo/build/petstore/create-users-with-array-input/index.html 22.3 kB
demo/build/petstore/create-users-with-list-input/index.html 22.3 kB
demo/build/petstore/delete-order/index.html 22.3 kB
demo/build/petstore/delete-pet/index.html 22.3 kB
demo/build/petstore/delete-user/index.html 22.6 kB
demo/build/petstore/find-pets-by-status/index.html 23 kB
demo/build/petstore/find-pets-by-tags/index.html 23.7 kB
demo/build/petstore/get-inventory/index.html 21.6 kB
demo/build/petstore/get-order-by-id/index.html 22.5 kB
demo/build/petstore/get-pet-by-id/index.html 23.1 kB
demo/build/petstore/get-user-by-name/index.html 22.6 kB
demo/build/petstore/login-user/index.html 23.2 kB
demo/build/petstore/logout-user/index.html 21.9 kB
demo/build/petstore/new-pet/index.html 22.5 kB
demo/build/petstore/pet/index.html 20.8 kB
demo/build/petstore/place-order/index.html 21.8 kB
demo/build/petstore/schemas/apiresponse/index.html 23.6 kB
demo/build/petstore/schemas/cat/index.html 37.4 kB
demo/build/petstore/schemas/category/index.html 24.6 kB
demo/build/petstore/schemas/dog/index.html 37.8 kB
demo/build/petstore/schemas/honeybee/index.html 37.9 kB
demo/build/petstore/schemas/id/index.html 21.7 kB
demo/build/petstore/schemas/order/index.html 25.7 kB
demo/build/petstore/schemas/pet/index.html 37.4 kB
demo/build/petstore/schemas/tag/index.html 23 kB
demo/build/petstore/schemas/user/index.html 45.5 kB
demo/build/petstore/store/index.html 20 kB
demo/build/petstore/subscribe-to-the-store-events/index.html 28.6 kB
demo/build/petstore/swagger-petstore-yaml/index.html 28.7 kB
demo/build/petstore/update-pet-with-form/index.html 22.5 kB
demo/build/petstore/update-pet/index.html 22.9 kB
demo/build/petstore/update-user/index.html 22.5 kB
demo/build/petstore/upload-file/index.html 22.3 kB
demo/build/petstore/user/index.html 20.5 kB

compressed-size-action

Copy link

github-actions bot commented May 9, 2025

Visit the preview URL for this PR (updated for commit fce1254):

https://docusaurus-openapi-36b86--pr1145-47ul77n7.web.app

(expires Sun, 08 Jun 2025 16:23:16 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

sserrata added 7 commits May 9, 2025 11:48
…me component testing

- Add ResizeObserver mock for Jest
- Use manual mocks for @docusaurus/theme-common/internal with useScrollPositionBlocker
- Apply // @ts-nocheck for TS module issues
- Clean up test setup for reliable CI
…me component testing

- Add ResizeObserver mock for Jest
- Use manual mocks for @docusaurus/theme-common/internal with useScrollPositionBlocker
- Apply // @ts-nocheck for TS module issues
- Clean up test setup for reliable CI
- Add and update all relevant mocks and config for Docusaurus theme testing
- Move ResizeObserver mock to setupTests.ts for global use
- Ensure both setupFilesAfterEnv entries are loaded in Jest config
- Remove redundant test file mocks
- Add TESTING.md for contributor guidance
- Re-add // @ts-nocheck to ApiTabs source for robust Docusaurus TS support
…mitations, update testing docs, and clean up test setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant