{"id":35387598,"url":"https://github.com/dev-five-git/bun-test-env-dom","last_synced_at":"2026-01-13T19:37:28.505Z","repository":{"id":331329945,"uuid":"1126198387","full_name":"dev-five-git/bun-test-env-dom","owner":"dev-five-git","description":"bun-test-env-dom is a preload library that provides a ready-to-use DOM","archived":false,"fork":false,"pushed_at":"2026-01-02T17:06:28.000Z","size":400,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-06T09:52:24.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dev-five-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"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}},"created_at":"2026-01-01T11:12:27.000Z","updated_at":"2026-01-02T17:06:14.000Z","dependencies_parsed_at":"2026-01-07T03:07:26.439Z","dependency_job_id":null,"html_url":"https://github.com/dev-five-git/bun-test-env-dom","commit_stats":null,"previous_names":["dev-five-git/bun-test-env-dom"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/dev-five-git/bun-test-env-dom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-five-git%2Fbun-test-env-dom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-five-git%2Fbun-test-env-dom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-five-git%2Fbun-test-env-dom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-five-git%2Fbun-test-env-dom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-five-git","download_url":"https://codeload.github.com/dev-five-git/bun-test-env-dom/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-five-git%2Fbun-test-env-dom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28397826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-01-02T07:32:08.037Z","updated_at":"2026-01-13T19:37:28.496Z","avatar_url":"https://github.com/dev-five-git.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bun-test-env-dom\n\nA preload library for Bun that provides a ready-to-use DOM environment for testing. It automatically sets up [happy-dom](https://github.com/capricorn86/happy-dom) and enables proper snapshot testing for React and HTML elements with beautifully formatted output.\n\n## Why?\n\nWithout this library, Bun's snapshot testing outputs unreadable React internals (FiberNode, stateNode, etc.):\n\n![Before - Unreadable snapshot output](media/before.png)\n\nWith `bun-test-env-dom`, snapshots are clean, formatted HTML that's easy to read and review:\n\n![After - Clean HTML snapshots](media/after.png)\n\n## Installation\n\n```bash\nbun add -d bun-test-env-dom\n```\n\n## Setup\n\nAdd the following to your `bunfig.toml`:\n\n```toml\n[test]\npreload = [\"bun-test-env-dom\"]\n```\n\nThat's it! The DOM environment is automatically configured when tests run.\n\n## Features\n\n### Snapshot Testing for React \u0026 HTML Elements\n\nSnapshot testing works seamlessly with both React elements and HTML elements. The HTML output is automatically formatted for readable snapshots.\n\n```tsx\nimport { expect, test } from 'bun:test'\nimport { render } from 'bun-test-env-dom'\n\ntest('React element snapshot', () =\u003e {\n  expect(\u003cComponent /\u003e).toMatchSnapshot()\n})\n\ntest('HTML element snapshot', () =\u003e {\n  const { container } = render(\u003cComponent /\u003e)\n  expect(container).toMatchSnapshot()\n})\n```\n\n### Re-exported @testing-library/react\n\nAll functions from `@testing-library/react` and `@testing-library/user-event` are re-exported, so you can import directly from `bun-test-env-dom`:\n\n```tsx\nimport { render, screen, fireEvent } from 'bun-test-env-dom'\n\ndescribe('HomePage', () =\u003e {\n  it('should render', () =\u003e {\n    const { container } = render(\u003cHomePage /\u003e)\n    expect(container).toMatchSnapshot()\n  })\n})\n```\n\n### Full TypeScript Support for Custom Matchers\n\nAll additional matchers from `@testing-library/jest-dom` are fully typed:\n\n```tsx\nimport { expect, test } from 'bun:test'\nimport { render } from 'bun-test-env-dom'\n\ntest('custom matchers', () =\u003e {\n  const { getByRole } = render(\u003cButton pressed\u003eClick me\u003c/Button\u003e)\n\n  expect(getByRole('button')).toBePressed()\n  expect(getByRole('button')).toBeVisible()\n  expect(getByRole('button')).toHaveTextContent('Click me')\n})\n```\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-five-git%2Fbun-test-env-dom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-five-git%2Fbun-test-env-dom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-five-git%2Fbun-test-env-dom/lists"}