diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 217fb26..0a33165 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,31 @@ jobs: - name: ๐Ÿž๏ธ Biome Check run: bun run check:biome + test: + name: ๐Ÿงช Test + runs-on: Ubuntu-Latest + + steps: + - name: ๐Ÿšš Checkout Repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: ๐Ÿž Setup Bun with Cache + uses: ./.github/actions/setup-bun-with-cache + + - name: ๐Ÿงช Run Tests + run: bun run test:cov + + - name: โ˜‚๏ธ Upload Coverage + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + - name: โ˜‚๏ธ Upload Test Results + if: ${{ !cancelled() }} + uses: codecov/test-results-action@9739113ad922ea0a9abb4b2c0f8bf6a4aa8ef820 # v1.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + build-check: name: ๐Ÿ› ๏ธ Build Check runs-on: Ubuntu-Latest diff --git a/.gitignore b/.gitignore index ddce69b..f73f2bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ node_modules/ dist/ .astro/ +coverage/ +junit.xml diff --git a/bun.lockb b/bun.lockb index 67986d0..94591ff 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 0d99c4f..3c4d18e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "build": "astro build", "preview": "astro preview", "check:astro": "astro check", - "check:biome": "biome check" + "check:biome": "biome check", + "test": "vitest run", + "test:cov": "vitest run --coverage" }, "dependencies": { "astro": "4.16.10", @@ -18,6 +20,8 @@ "@astrojs/check": "0.9.4", "@biomejs/biome": "1.9.4", "@types/node": "22.9.0", - "astrobook": "0.5.1" + "@vitest/coverage-v8": "2.1.4", + "astrobook": "0.5.1", + "vitest": "2.1.4" } } diff --git a/src/components/Bio/Bio.test.ts b/src/components/Bio/Bio.test.ts new file mode 100644 index 0000000..48aac20 --- /dev/null +++ b/src/components/Bio/Bio.test.ts @@ -0,0 +1,18 @@ +import { experimental_AstroContainer as AstroContainer } from "astro/container"; +import { describe, expect, test } from "vitest"; + +import Bio from "./Bio.astro"; +import * as stories from "./story.ts"; + +describe("Bio", () => { + for (const [name, props] of Object.entries(stories)) { + test(name, async () => { + const container: AstroContainer = await AstroContainer.create(); + const result: string = await container.renderToString(Bio, { props }); + + expect(result).toContain(`>${props.name}`); + expect(result).toContain(`>${props.description}`); + expect(result).toContain(` + +import { getViteConfig } from "astro/config"; + +export default getViteConfig({ + test: { + reporters: ["verbose", ["junit", { suiteName: "Component Tests" }]], + outputFile: "junit.xml", + }, +});