Skip to content

Commit

Permalink
Merge pull request #8 from vuejs-jp/feat/vitest
Browse files Browse the repository at this point in the history
Feat/vitest
  • Loading branch information
jiyuujin authored Feb 13, 2024
2 parents 7057ed4 + 11b8381 commit 5434a70
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
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.

0 comments on commit 5434a70

Please sign in to comment.