{"id":49062484,"url":"https://github.com/pokujs/dom","last_synced_at":"2026-04-20T03:05:40.953Z","repository":{"id":349377403,"uuid":"1202046329","full_name":"pokujs/dom","owner":"pokujs","description":"Shared DOM testing core for Poku framework adapters.","archived":false,"fork":false,"pushed_at":"2026-04-05T16:01:28.000Z","size":92,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-05T17:27:59.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pokujs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["wellwelwel"]}},"created_at":"2026-04-05T14:24:11.000Z","updated_at":"2026-04-05T16:01:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pokujs/dom","commit_stats":null,"previous_names":["pokujs/dom"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pokujs/dom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokujs%2Fdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokujs%2Fdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokujs%2Fdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokujs%2Fdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pokujs","download_url":"https://codeload.github.com/pokujs/dom/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokujs%2Fdom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32031070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-20T03:05:36.178Z","updated_at":"2026-04-20T03:05:40.945Z","avatar_url":"https://github.com/pokujs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/wellwelwel"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg height=\"180\" alt=\"Poku Logo\" src=\"https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/poku.svg\"\u003e\n\n# @pokujs/dom\n\nShared DOM testing core for Poku framework adapters.\n\n\u003c/div\u003e\n\n---\n\n@pokujs/dom centralizes cross-framework testing infrastructure used by adapter libraries such as @pokujs/react and @pokujs/vue.\n\nUse this package when building or maintaining framework adapters that need:\n\n- Runtime command injection for Node, Bun, and Deno.\n- In-process test environment setup.\n- Metrics normalization and reporting.\n- happy-dom/jsdom environment bootstrap.\n- Shared testing runtime primitives.\n\n## Installation\n\n```bash\nnpm i @pokujs/dom\n```\n\n## Usage\n\n### 1) Build runtime option prefixes and parse flags\n\n```ts\nimport {\n  createRuntimeOptionArgPrefixes,\n  parseRuntimeOptions,\n} from '@pokujs/dom';\n\nconst prefixes = createRuntimeOptionArgPrefixes('poku-react');\nconst runtimeOptions = parseRuntimeOptions(prefixes);\n```\n\n### 2) Create a framework plugin factory\n\n```ts\nimport {\n  createFrameworkTestingPluginFactory,\n  type FrameworkDescriptor,\n} from '@pokujs/dom';\n\nconst descriptor: FrameworkDescriptor = {\n  pluginName: 'react-testing',\n  packageTag: '@pokujs/react',\n  runtimeArgBase: 'poku-react',\n  metricMessageType: 'POKU_REACT_RENDER_METRIC',\n  metricBatchMessageType: 'POKU_REACT_RENDER_METRIC_BATCH',\n};\n\nconst { createTestingPlugin } = createFrameworkTestingPluginFactory(\n  descriptor,\n  import.meta.url\n);\n\nexport const createReactTestingPlugin = createTestingPlugin;\n```\n\n### 3) Reuse DOM setup helpers\n\n```ts\nimport { setupHappyDomEnvironment, setupJsdomEnvironment } from '@pokujs/dom';\n```\n\n### 4) Reuse shared testing runtime helpers\n\n```ts\nimport {\n  createRenderMetricsEmitter,\n  createScreen,\n  getNow,\n} from '@pokujs/dom';\n```\n\n## Contracts\n\nAdapter packages should follow these contracts.\n\n### FrameworkDescriptor contract\n\n- pluginName: Plugin registration name.\n- packageTag: Human-readable package tag for messages.\n- runtimeArgBase: Prefix base used to generate runtime CLI flags.\n- metricMessageType: IPC type for single render metrics.\n- metricBatchMessageType: IPC type for batch render metrics.\n- testFileExtensions (optional): Test file extensions the runner should intercept.\n\n### Runtime options contract\n\nparseRuntimeOptions returns:\n\n- domUrl: DOM URL used by happy-dom/jsdom setup.\n- metricsEnabled: Whether metrics collection is active.\n- minMetricMs: Drop metrics below this threshold.\n- metricBatchSize: Batch size before immediate flush.\n- metricFlushMs: Flush interval while buffering.\n\n### Metrics contract\n\ncreateMetricsSummary returns either null or:\n\n- totalCaptured: Number of collected metrics.\n- totalReported: Number of top metrics reported.\n- topSlowest: Sorted metrics by duration descending.\n\n### Testing runtime contract\n\ncreateRenderMetricsEmitter provides:\n\n- emitRenderMetric(componentName, durationMs)\n- flushMetricBuffer()\n- clearMetricFlushTimer()\n\nThese APIs are framework-agnostic. Adapter packages remain responsible for framework-specific semantics such as act, nextTick, render lifecycle, and hook/composable harness behavior.\n\n## Release and CI/CD\n\nThis package includes:\n\n- CI build and lint workflows.\n- Node, Bun, and Deno compatibility workflows.\n- CodeQL workflow and config.\n- Release Please + npm publish workflow.\n\n## Development\n\n```bash\nnpm ci\nnpm run check\nnpm run build\n```\n\n## Testing\n\n```bash\nnpm test\nnpm run test:bun\nnpm run test:deno\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokujs%2Fdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpokujs%2Fdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokujs%2Fdom/lists"}