Skip to content

Commit

Permalink
chore: add testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bisquit committed Jul 11, 2023
1 parent 5c42a8f commit 5ffea00
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'

- name: install
run: pnpm i

- name: validate
run: pnpm validate

- name: test
run: pnpm test:ci

- name: upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/clover.xml
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ dist-ssr

# package
*.vsix

# vitest coverage
coverage
12 changes: 12 additions & 0 deletions CONTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ Open `DEBUG CONSOLE` (Cmd + Shift + y) to see logs.

After modifying, 「Cmd + Shift + P」 > 「Developer: Reload Window」 in extension host window.

## test

These are also checked in CI.

```sh
# unit testing
pnpm test

# lint, typecheck
pnpm validate
```

## PR

Use `czg` or make sure to prefix type.
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
"esbuild": "pnpm run esbuild-base --sourcemap",
"esbuild:watch": "pnpm run esbuild-base --sourcemap --watch",
"lint": "eslint \"src/**/*.ts\"",
"typecheck": "tsc --noEmit && echo 'Type checking passed!'",
"validate": "pnpm run lint && pnpm run typecheck",
"test": "vitest",
"test:ci": "vitest run",
"test:coverage": "vitest --coverage.enabled --coverage.provider=v8 --coverage.all --coverage.clean --coverage.include=src --coverage.exclude=src/extension.ts",
"test:ci": "pnpm run test:coverage --run",
"vsce:package": "pnpm vsce package --no-dependencies",
"vsce:publish": "pnpm vsce publish --no-dependencies"
},
Expand All @@ -44,6 +47,7 @@
"@types/vscode": "^1.79.1",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"@vitest/coverage-v8": "^0.33.0",
"esbuild": "^0.18.10",
"eslint": "^8.43.0",
"eslint-plugin-perfectionist": "^1.4.0",
Expand Down
158 changes: 158 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/utils/__test__/color.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect, test } from 'vitest';

import { getColorHexFromString } from '../color';

test('getColorHexFromString()', async () => {
expect(getColorHexFromString('a')).toBe('#d2c679');
});

0 comments on commit 5ffea00

Please sign in to comment.