Skip to content

Commit

Permalink
test: use Vitest for testing
Browse files Browse the repository at this point in the history
Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
  • Loading branch information
threeal committed Dec 27, 2024
1 parent fc2779d commit abb1376
Show file tree
Hide file tree
Showing 6 changed files with 982 additions and 2,490 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This template provides a basic Node.js project containing a sample library writt

- Minimal Node.js project written in TypeScript with [ESM](https://nodejs.org/api/esm.html) support.
- Uses [Yarn](https://yarnpkg.com/) as the package manager, with [Plug'n'Play](https://yarnpkg.com/features/pnp) support.
- Supports formatting with [Prettier](https://prettier.io/), linting with [ESLint](https://eslint.org/), and testing with [Jest](https://jestjs.io/).
- Supports formatting with [Prettier](https://prettier.io/), linting with [ESLint](https://eslint.org/), and testing with [Vitest](https://vitest.dev/).
- Preconfigured workflows for [Dependabot](https://docs.github.com/en/code-security/dependabot) and [GitHub Actions](https://github.com/features/actions).

## Usage
Expand Down Expand Up @@ -82,7 +82,7 @@ yarn build

### Testing the Library

Test files in this template are named `*.test.ts` and typically correspond to the source files being tested. This template uses [Jest](https://jestjs.io/) as the testing framework. For more information on testing with Jest, refer to [this documentation](https://jestjs.io/docs/getting-started).
Test files in this template are named `*.test.ts` and typically correspond to the source files being tested. This template uses [Vitest](https://vitest.dev/) as the testing framework. For more information on testing with Vitest, refer to [this documentation](https://vitest.dev/guide/).

After creating your test files, run tests with:

Expand Down
20 changes: 0 additions & 20 deletions jest.config.json

This file was deleted.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,21 @@
"format": "prettier --write --cache .",
"lint": "eslint",
"prepack": "tsc",
"test": "jest"
"test": "vitest"
},
"dependencies": {
"yargs": "^17.7.2"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.2",
"@types/yargs": "^17.0.33",
"@vitest/coverage-v8": "^2.1.8",
"eslint": "^9.17.0",
"jest": "^29.7.0",
"prettier": "^3.4.2",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.2"
"typescript-eslint": "^8.18.2",
"vitest": "^2.1.8"
},
"packageManager": "yarn@4.5.3"
}
1 change: 1 addition & 0 deletions src/sequence.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { it, expect } from "vitest";
import { fibonacciSequence } from "./sequence.js";

it("should generate a fibonacci sequence", () => {
Expand Down
13 changes: 13 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
watch: false,
coverage: {
all: false,
enabled: true,
reporter: ["text"],
thresholds: { 100: true },
},
},
});
Loading

0 comments on commit abb1376

Please sign in to comment.