Skip to content

Feat/improve runner#67

Merged
kevinccbsg merged 8 commits into
mainfrom
feat/improve-runner
Oct 25, 2025
Merged

Feat/improve runner#67
kevinccbsg merged 8 commits into
mainfrom
feat/improve-runner

Conversation

@kevinccbsg

Copy link
Copy Markdown
Member

This pull request introduces a major refactor of the test runner infrastructure, decoupling test and suite registration from the main twd export and moving it into a new runner module. It also updates the test registry to use a Map-based handler system, introduces a new TestRunner class, and updates all internal and example tests to use the new API. Additionally, it exposes new subpath exports in package.json and improves plugin integration for Vite.

Test runner and registry refactor:

  • Introduced a new runner module (src/runner.ts) that manages test and suite registration using a Handler map, supports nested suites, and provides new APIs for describe, it, it.only, it.skip, beforeEach, afterEach, and test clearing. Also adds a TestRunner class for executing tests with proper hook and status handling.
  • Updated all internal tests and example test files to import test runner functions from the new runner module, replacing previous registry and function usage. [1] [2] [3] [4]
  • Removed the old registry-based test infrastructure and its associated tests.

API and package structure changes:

  • Updated package.json to add subpath exports for ./runner and ./vite-plugin, exposing their types and builds for external consumers.
  • Updated src/index.ts to only export twd from the main entry, removing test runner functions and plugin exports, which are now available via subpaths.

Vite plugin improvements:

  • Updated the Vite example configuration to import and use the removeMockServiceWorker plugin from the new subpath.

Mock Service Worker improvements:

  • Enhanced mock-sw.js to improve URL regex validation, response handling for special HTTP status codes, and updated logging/versioning.

Test coverage updates:

  • Significantly expanded test coverage for the new runner, including tests for nested hooks, .only/.skip logic, and correct hook execution order. [1] [2] [3]

Test runner and registry refactor:

  • Added a new runner module that manages test/suite registration with a map-based handler system, supports nested suites, hooks, and provides a TestRunner class for execution.
  • Updated all tests and examples to use the new runner API, replacing the old registry and function imports. [1] [2] [3] [4]
  • Removed the legacy registry infrastructure and its tests.

API and package structure:

  • Added subpath exports for ./runner and ./vite-plugin in package.json for better modularity and external usage.
  • Cleaned up src/index.ts to only export the main twd API, moving runner and plugin exports to subpaths.

Vite and mock service worker:

  • Updated Vite example to use the new plugin subpath.
  • Improved mock-sw.js for better URL regex handling and response management.

Test coverage:

  • Expanded and updated runner tests to cover new features, correct hook order, and .only/.skip logic. [1] [2] [3]

This closes #36

@kevinccbsg kevinccbsg merged commit 72ca85e into main Oct 25, 2025
4 checks passed
@kevinccbsg kevinccbsg deleted the feat/improve-runner branch October 25, 2025 19:26
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.

[runner] Add after each command or after all

1 participant