Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/vitest #8

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,22 @@ jobs:

- name: Lint check
run: bun lint

- name: Unit test
run: bun vitest

unit-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.19.0]

steps:
- uses: actions/checkout@v4

- name: Install packages
uses: ./.github/actions/install-packages

- name: Unit test
run: bun vitest
6 changes: 4 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
"lint": "eslint . --ext js,jsx,ts,tsx,vue --ignore-path .eslintignore",
"lint-fix": "eslint . --ext js,jsx,ts,tsx,vue --ignore-path .eslintignore --fix",
"cypress:open": "cypress open --config-file tests/cypress.config.ts",
"postinstall": "nuxt prepare"
"postinstall": "nuxt prepare",
"vitest": "vitest"
},
"devDependencies": {
"@vuejs-jp/eslint-config": "workspace:*",
"@vuejs-jp/typescript-config": "workspace:*",
"@vuejs-jp/vuefes-ui": "workspace:*",
"cypress": "13.6.4",
"nuxt": "3.10.0"
"nuxt": "3.10.0",
"vitest": "1.2.2"
}
}
3 changes: 3 additions & 0 deletions apps/web/tests/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({})
14 changes: 14 additions & 0 deletions apps/web/tests/vitest/sample.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// the implementation
export function add(...args: number[]) {
return args.reduce((a, b) => a + b, 0)
}

// in-source test suites
if (import.meta.vitest) {
const { it, expect } = import.meta.vitest
it('add', () => {
expect(add()).toBe(0)
expect(add(1)).toBe(1)
expect(add(1, 2, 3)).toBe(6)
})
}
10 changes: 10 additions & 0 deletions apps/web/tests/vitest/types/vitest.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference types="vite/client" />

interface ImportMetaVitest {
readonly it: Function
readonly expect: Function
}

interface ImportMeta {
readonly vitest: ImportMetaVitest
}
Binary file modified bun.lockb
Binary file not shown.
Loading