From 9a2c908f8fe405750d3f9cc55f21f15ba53fe4f2 Mon Sep 17 00:00:00 2001 From: Richard Zampieri Date: Sun, 17 Sep 2023 15:37:50 -0700 Subject: [PATCH] feat: vite test env --- .eslintrc.cjs | 2 +- package.json | 9 +++++++-- test/test.spec.ts | 3 +++ tsconfig.json | 4 ++-- vitest.config.ts | 16 ++++++++++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 test/test.spec.ts create mode 100644 vitest.config.ts diff --git a/.eslintrc.cjs b/.eslintrc.cjs index a7e0068..83139c8 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,4 +1,3 @@ -/* eslint-env node */ module.exports = { parser: "@typescript-eslint/parser", parserOptions: { @@ -15,6 +14,7 @@ module.exports = { "node_modules/*", "expressots.config.ts", "commitlint.config.ts", + "vite.config.ts", ], rules: { "@typescript-eslint/interface-name-prefix": "off", diff --git a/package.json b/package.json index 4cfc761..84ee3fd 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,10 @@ "format": "prettier --write \"./src/**/*.ts\" --cache", "lint": "eslint \"./src/**/*.ts\"", "lint:fix": "eslint \"./src/**/*.ts\" --fix", - "release": "release-it" + "release": "release-it", + "test": "vitest run", + "test:watch": "vitest", + "test:coverage": "vitest run --coverage" }, "dependencies": { "@expressots/boost-ts": "^1.1.1", @@ -76,7 +79,9 @@ "release-it": "^16.1.5", "rimraf": "^4.1.2", "ts-node-dev": "^2.0.0", - "typescript": "^4.9.5" + "typescript": "^4.9.5", + "vite": "^4.4.9", + "vitest": "^0.34.4" }, "release-it": { "git": { diff --git a/test/test.spec.ts b/test/test.spec.ts new file mode 100644 index 0000000..5628bdb --- /dev/null +++ b/test/test.spec.ts @@ -0,0 +1,3 @@ +it("pass", () => { + expect(true).toBe(true); +}); diff --git a/tsconfig.json b/tsconfig.json index 7b4baa4..2b02467 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,8 +15,8 @@ "skipLibCheck": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, - "types": ["node"] + "types": ["node", "vitest/globals"] }, "include": ["./src"], - "exclude": ["node_modules"] + "exclude": ["node_modules", "test/**/*.spec.ts"] } diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..16f581d --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,16 @@ +import { defineConfig } from "vitest/config"; + +/** + * @see {@link https://vitejs.dev/config/} + * @see {@link https://vitest.dev/config/} + */ +export default defineConfig({ + test: { + globals: true, + coverage: { + all: true, + }, + // ref: https://vitest.dev/config/#testtimeout + testTimeout: 10000, + }, +});