Skip to content

Feat/mock component#94

Merged
kevinccbsg merged 8 commits into
mainfrom
feat/mock-component
Nov 18, 2025
Merged

Feat/mock component#94
kevinccbsg merged 8 commits into
mainfrom
feat/mock-component

Conversation

@kevinccbsg

Copy link
Copy Markdown
Member

Description

This pull request introduces comprehensive support for component mocking in the TWD testing framework, enabling developers to replace React components with mock implementations during tests. The update includes new APIs, documentation, example usage, and test coverage for component mocking, as well as minor dependency updates and improvements to the example app.

Component Mocking Feature:

  • Added mockComponent and clearComponentMocks APIs to twd, allowing users to mock and reset React components by name for isolated testing. (src/twd.ts, src/index.ts, [1] [2] [3] [4]
  • Exported the MockedComponent wrapper for marking components as mockable. (src/index.ts, src/index.tsR4)

Documentation Enhancements:

  • Added a dedicated component-mocking.md guide with setup instructions, usage patterns, advanced examples, best practices, and troubleshooting tips. (docs/component-mocking.md, docs/component-mocking.mdR1-R355)
  • Updated API reference documentation to describe mockComponent and clearComponentMocks usage with code samples. (docs/api/twd-commands.md, docs/api/twd-commands.mdR853-R974)
  • Linked the new documentation in the sidebar navigation. (docs/.vitepress/config.mts, docs/.vitepress/config.mtsR57)

Example App Updates:

Internal & Test Coverage:

Dependency Updates:

  • Bumped several dev dependencies for React, Vite, Vitest, and jsdom to latest minor versions for compatibility and stability. (package.json, package.jsonL69-R79)

Fixes #92

Type of Change

Please delete options that are not relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • All existing tests pass
  • New and existing unit tests pass locally
  • I have tested this change manually

Test Details

Unit tests and E2E tests.

Documentation

  • I have updated the documentation accordingly
  • I have added/updated code comments where necessary
  • The changes are reflected in the relevant documentation files

@kevinccbsg kevinccbsg merged commit 112a4f3 into main Nov 18, 2025
5 checks passed
@kevinccbsg kevinccbsg deleted the feat/mock-component branch November 18, 2025 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Mockable Components in TWD

1 participant