{"_id":"@advastro/astro-component-tester","name":"@advastro/astro-component-tester","dist-tags":{"latest":"0.9.0"},"versions":{"0.9.0":{"name":"@advastro/astro-component-tester","version":"0.9.0","description":"Utility to test Astro components","keywords":["astro","astro-component","testing","test","unit-test","unit-testing"],"homepage":"https://github.com/advanced-astro/astro-component-tester#readme","repository":{"type":"git","url":"git+https://github.com/advanced-astro/astro-component-tester.git"},"license":"MIT","author":{"name":"Marc Krebstakies","email":"rdwz@pm.me","url":"https://github.com/rdwz"},"type":"module","exports":{".":{"require":"./dist/cjs/index.js","import":"./dist/index.js","types":"./dist/index.d.ts"}},"main":"./dist/cjs/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"npm run build:esm && npm run build:cjs","build:cjs":"tsc --module commonjs --outDir dist/cjs && npm run replace-cjs:dirname","build:esm":"tsc","dev":"tsc --watch","format":"biome format --fix","lint":"biome lint","prepublishOnly":"npm run build","replace-cjs:dirname":"replace-in-file ./dist/cjs/**  --configFile=./scripts/replace-in-files-dirname.json"},"devDependencies":{"@biomejs/biome":"^2.5.5","@types/node":"^26.1.1","astro":"^7.1.3","replace-in-file":"^8.4.0","typescript":"^7.0.2"},"peerDependencies":{"astro":"^7.1.3"},"packageManager":"bun@1.3.14","_id":"@advastro/astro-component-tester@0.9.0","gitHead":"edfd2a77fa7c19c066a458567a59be663c4210f4","bugs":{"url":"https://github.com/advanced-astro/astro-component-tester/issues"},"_nodeVersion":"24.18.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-LbGzKbyjOqPrL6dYzZb7mwTPOpfLidmAJmXDjwlxCXQM6429/YNT1Ms2I+7cfPo8vVRmt/3BAK3Se9bobDRtsQ==","shasum":"dd92d8783e15934de578e3181b14a2113767e4ca","tarball":"https://registry.npmjs.org/@advastro/astro-component-tester/-/astro-component-tester-0.9.0.tgz","fileCount":11,"unpackedSize":17420,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBOIQ6dannsCNSLSmzKGobOHfL4SEPjSfOZjF3j5inT6AiEArRy+ILgzs+W7XB1QUBBFXYbN4eTmc8J2xg9JPnjfoS8="}]},"_npmUser":{"name":"redwerkz","email":"yred@tuta.io"},"directories":{},"maintainers":[{"name":"redwerkz","email":"yred@tuta.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/astro-component-tester_0.9.0_1784641603336_0.09436501857974022"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-21T13:46:43.136Z","0.9.0":"2026-07-21T13:46:43.482Z","modified":"2026-07-21T13:46:43.747Z"},"maintainers":[{"name":"redwerkz","email":"yred@tuta.io"}],"description":"Utility to test Astro components","homepage":"https://github.com/advanced-astro/astro-component-tester#readme","keywords":["astro","astro-component","testing","test","unit-test","unit-testing"],"repository":{"type":"git","url":"git+https://github.com/advanced-astro/astro-component-tester.git"},"author":{"name":"Marc Krebstakies","email":"rdwz@pm.me","url":"https://github.com/rdwz"},"bugs":{"url":"https://github.com/advanced-astro/astro-component-tester/issues"},"license":"MIT","readme":"# @advastro/astro-component-tester\n\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![npm version](https://img.shields.io/npm/v/@advastro/astro-component-tester.svg)](https://npmjs.com/package/@advastro/astro-component-tester)\n[![npm downloads](https://img.shields.io/npm/dt/@advastro/astro-component-tester.svg)](https://npmjs.com/package/@advastro/astro-component-tester)\n![Biome](https://img.shields.io/badge/Code%20Style-Biome-5F45FF?logo=biome)\n![Bun](https://img.shields.io/badge/Package%20Manager-Bun-000000?logo=bun)\n\nA lightweight utility that builds an Astro component in a temporary project and returns its rendered HTML.\nIdeal for testing, debugging, or quickly inspecting a single component.\n\nThis package is a modernized fork of the original `astro-component-tester` component.\n\n## Why?\n\nAstro components often rely on the full Astro build pipeline.\nTraditional test setups struggle with this, so this tool spins up a minimal Astro project, builds your component in isolation, and gives you the exact output Astro would produce.\n\n## Installation\n\n```sh\nnpm install @advastro/astro-component-tester\n# or\nyarn add @advastro/astro-component-tester\n# or\npnpm install @advastro/astro-component-tester\n# or\nbun install @advastro/astro-component-tester\n```\n\n## Use\n\nExamples below use Mocha and Chai, but any test framework works.\n\n```js\nimport { expect } from 'chai'\nimport { getComponentOutput } from '@advastro/astro-component-tester'\n\ndescribe('Component', async () => {\n  let component\n\n  before(async () => {\n    component = await getComponentOutput('./src/Component.astro')\n  })\n\n  it('example component should say hello', () => {\n    expect(component.html).to.contain('Hello')\n  })\n})\n\n```\n\n### Passing Props\n\nComponent:\n\n```astro\n---\nconst { mySuperProp } = Astro.props\n---\n\n<div>{ mySuperProp + 1 }</div>\n```\n\nTest:\n\n```js\nimport { expect } from 'chai'\nimport { getComponentOutput } from '@advastro/astro-component-tester'\n\ndescribe('Component', async () => {\n  let component\n\n  before(async () => {\n    component = await getComponentOutput('./src/Component.astro', { mySuperProp: 1 })\n  })\n\n  it('example component should return 2', () => {\n    expect(component.html).to.contain(2)\n  })\n})\n```\n\n#### Passing Astro Options\n\nUseful when testing components that rely on specific renderers:\n\n```js\nimport { expect } from 'chai'\nimport { getComponentOutput } from '@advastro/astro-component-tester'\n\ndescribe('Component', async () => {\n  let component\n\n  before(async () => {\n    component = await getComponentOutput('./src/Component.astro', {}, { astroOptions: { renderers: ['@astrojs/renderer-svelte'] } })\n  })\n\n  it('example component should say hello using a Svelte component', () => {\n    expect(component.html).to.contain('Hello from Svelte')\n  })\n})\n```\n\n## Limitations\n\n### Context-specific variables\n\nComponents are built in an isolated environment.\nContext-dependent values (e.g. `Astro.request` ) will not reflect real routing or page state.\nMocking such values is currently not supported.\n\n## Links\n\n- [License (MIT)](LICENSE)\n- [Website](https://astro.build/)\n","readmeFilename":"README.md","_rev":"1-454e687e3a74dd9b5cf9ba508a68e7ab"}