Skip to content

Commit

Permalink
feat(scaffolding): replaced jest and ts-jest with vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Sep 16, 2024
1 parent 95ff66c commit 411bcae
Show file tree
Hide file tree
Showing 19 changed files with 670 additions and 2,150 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ jobs:
key: ${{ runner.os }}-${{ matrix.node }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node }}-node-
- uses: pnpm/[email protected]
with:
version: 7.4.1
run_install: false
- name: Install dependencies
run: pnpm i
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@
"typecheck": "turbo run typecheck",
"lint:ci": "turbo run lint:ci",
"lint": "turbo run lint",
"test": "turbo run test",
"test:unit": "turbo run test:unit",
"test:integration": "turbo run test:integration",
"test:ci": "turbo run test:ci",
"test": "pnpm -r --if-present test",
"test:unit": "pnpm -r --if-present test:unit",
"test:integration": "pnpm -r --if-present test:integration",
"prepare": "husky"
},
"devDependencies": {
"@biomejs/biome": "^1.9.0",
"@types/jest": "^29.1.2",
"@types/node": "20.9.0",
"husky": "^9.1.6",
"jest": "^29.2.0",
"lint-staged": "^15.2.10",
"rimraf": "^3.0.2",
"ts-jest": "29.0.3",
"turbo": "^2.1.2",
"typescript": "^4.8.4"
"typescript": "^5.6.0",
"vitest": "^2.1.0"
},
"packageManager": "[email protected]",
"pre-commit": "lint-staged",
Expand Down
13 changes: 13 additions & 0 deletions packages/common-utils/__tests__/integration/uses-internet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('should be able to connect to the internet', () => {
it('/todos', async () => {
const response = await fetch('https://jsonplaceholder.typicode.com/todos')
const todos = await response.json()
expect(todos.length).toBeGreaterThan(0)
})

it('/users', async () => {
const response = await fetch('https://jsonplaceholder.typicode.com/users')
const users = await response.json()
expect(users.length).toBeGreaterThan(0)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`sum > sum([]) = 0 1`] = `0`;

exports[`sum > sum([2, 3, 0, 1]) = 6 1`] = `0`;
2 changes: 2 additions & 0 deletions packages/common-utils/__tests__/unit/sum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { sum } from '../../src'
describe('sum', () => {
it('sum([]) = 0', () => {
expect(sum([])).toBe(0)
expect(sum([])).toMatchSnapshot()
})

it('sum([2, 3, 0, 1]) = 6', () => {
expect(sum([2, 3, 0, 1])).toEqual(6)
expect(sum([])).toMatchSnapshot()
})
})
16 changes: 10 additions & 6 deletions packages/common-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
"version": "0.1.0",
"description": "Library that contains common utility functions",
"main": "./build/index.js",
"exports": {
".": {
"import": "./build/index.js",
"require": "./build/index.js",
"types": "./build/index.d.ts"
}
},
"scripts": {
"clean": "rimraf build",
"build": "pnpm clean && tsc",
"typecheck": "tsc",
"lint:ci": "biome ci",
"lint": "biome check --fix --unsafe",
"pretest": "jest --clearCache",
"test": "pnpm test:ci",
"test:unit": "JEST_LIB_UNDER_TEST=common-utils jest -c ../jest/jest.config.unit.mjs",
"test:integration": "JEST_LIB_UNDER_TEST=common-utils jest -c ../jest/jest.config.integration.mjs",
"test:local": "JEST_LIB_UNDER_TEST=common-utils jest -c ../jest/jest.config.local.mjs",
"test:ci": "JEST_LIB_UNDER_TEST=common-utils jest -c ../jest/jest.config.ci.mjs --runInBand"
"test": "vitest --workspace ../../vitest.workspace.ts run",
"test:unit": "vitest --workspace ../../vitest.workspace.ts --project unit run",
"test:integration": "vitest --workspace ../../vitest.workspace.ts --project integration run"
}
}
5 changes: 5 additions & 0 deletions packages/example/__tests__/unit/silly.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('basic', () => {
it('silly example', () => {
expect([]).toHaveLength(0)
})
})
2 changes: 1 addition & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"typecheck": "tsc",
"lint:ci": "biome ci",
"lint": "biome check --fix --unsafe",
"pretest": "jest --clearCache"
"test:unit": "vitest --workspace ../../vitest.workspace.ts --project unit run"
},
"dependencies": {
"@jkomyno/common-utils": "workspace:*"
Expand Down
13 changes: 0 additions & 13 deletions packages/jest/constants.mjs

This file was deleted.

17 changes: 0 additions & 17 deletions packages/jest/jest.config.ci.mjs

This file was deleted.

12 changes: 0 additions & 12 deletions packages/jest/jest.config.integration.mjs

This file was deleted.

16 changes: 0 additions & 16 deletions packages/jest/jest.config.local.mjs

This file was deleted.

37 changes: 0 additions & 37 deletions packages/jest/jest.config.mjs

This file was deleted.

11 changes: 0 additions & 11 deletions packages/jest/jest.config.unit.mjs

This file was deleted.

Loading

0 comments on commit 411bcae

Please sign in to comment.