diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 00000000..0f597557 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,48 @@ +name: Run Unit Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + unit-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + name: Checkout Repository 🫠 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + - run: npm ci + - run: npm test + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + - run: npm ci + - run: npm run build + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + - run: npm ci + - run: npm test -- --coverage --run + - uses: actions/upload-artifact@v3 + name: Archive coverage report + with: + name: coverage-report + path: coverage diff --git a/package.json b/package.json index 33f18883..c2b81327 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "test:all": "vitest", "test:accessibility": "vitest accessibility --run", "coverage": "vitest --coverage --run", - "test": "echo \"Navigate into an example and run the tests from there!\" && exit 1", + "test": "vitest", "build": "tsc && vite build", "preview": "vite preview" }, diff --git a/src/components/button.tsx b/src/components/button.tsx index 97838a19..ec493cdb 100644 --- a/src/components/button.tsx +++ b/src/components/button.tsx @@ -1,4 +1,4 @@ -import colors from '@/colors.json'; +import colors from '@/src/colors.json'; import { css } from '@emotion/css'; import { ComponentPropsWithoutRef } from 'react'; diff --git a/src/lib/polygon.test.ts b/src/lib/polygon.test.ts index 5f1c03e5..f775f722 100644 --- a/src/lib/polygon.test.ts +++ b/src/lib/polygon.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, it, expect } from 'vitest'; -import { createPolygon, Polygon } from 'src/lib/polygon'; +import { createPolygon, Polygon } from '$lib/polygon'; type ContextWithPolygon = { polygon: Polygon; diff --git a/vitest.config.ts b/vitest.config.ts index bfdb94e7..84c98601 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ ['**/*.component.test.ts', 'jsdom'], ], coverage: { - statements: 54.92, + statements: 50, thresholdAutoUpdate: true, include: ['src/**/*'], exclude: [