diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a030ea8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: Codecov +on: + push: + branches: [ "*" ] +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install dependencies + run: npm install + + - name: Run tests and generate coverage + run: npm run test -- --coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} # Required if the repo is private + files: ./coverage/lcov.info # Path to the lcov report + flags: unittests # Optional: Flag for specific test type + name: codecov-umbrella # Optional: Custom name for coverage report + fail_ci_if_error: true # Optional: Fail CI if upload fails \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json new file mode 100644 index 0000000..702ae26 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "devDependencies": { + "@vitest/coverage-v8": "^2.1.4", + "vitest": "^2.1.4" + }, + "scripts": { + "test": "vitest" + } +} diff --git a/tests/sample.test.ts b/tests/sample.test.ts new file mode 100644 index 0000000..631ca0d --- /dev/null +++ b/tests/sample.test.ts @@ -0,0 +1,7 @@ +import { describe, it, expect } from 'vitest'; + +describe('Sample Test', () => { + it('should pass', () => { + expect(true).toBe(true); + }); +}); diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..7d1fc13 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite'; +import { configDefaults } from 'vitest/config'; + +export default defineConfig({ + test: { + include: ['tests/**/*.test.ts'], // Adjust this to your test file location + coverage: { + provider: 'v8', + reporter: ['text', 'json', 'lcov'], + reportsDirectory: './coverage', + }, + }, +}); \ No newline at end of file