Skip to content

Commit 82fa1a2

Browse files
committed
jest => vitest
1 parent 4434b17 commit 82fa1a2

8 files changed

+48
-34
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
node-version: '16'
2222
- run: npm install
23-
- run: npm test
23+
- run: npm test -- --run --no-cache
2424
node18:
2525
name: Node 18
2626
runs-on: ubuntu-22.04
@@ -32,7 +32,7 @@ jobs:
3232
with:
3333
node-version: '18'
3434
- run: npm install
35-
- run: npm test
35+
- run: npm test -- --run --no-cache
3636
node20:
3737
name: Node 20
3838
runs-on: ubuntu-22.04
@@ -46,7 +46,7 @@ jobs:
4646
- run: npm install
4747
- run: npm run lint
4848
- run: npm run cs
49-
- run: npm test -- --coverage --no-cache
49+
- run: npm test -- --run --coverage --no-cache
5050
- run: npm run infection
5151
env:
5252
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

jest.config.cjs

-15
This file was deleted.

package.json

+8-10
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
"repository": "chubbyts/chubbyts-http-multipart",
1515
"scripts": {
1616
"build": "node ./build.js",
17-
"cs-fix": "./node_modules/prettier/bin/prettier.cjs --write src tests",
18-
"cs": "./node_modules/prettier/bin/prettier.cjs --check src tests",
17+
"cs-fix": "prettier --write src tests",
18+
"cs": "prettier --check src tests",
1919
"infection": "stryker run",
2020
"lint-fix": "eslint src tests --fix",
2121
"lint": "eslint src tests",
2222
"prepare": "npm run build",
23-
"test": "jest"
23+
"test": "vitest"
2424
},
2525
"prettier": {
2626
"printWidth": 120,
@@ -51,18 +51,16 @@
5151
"@chubbyts/chubbyts-function-mock": "^1.4.1",
5252
"@chubbyts/chubbyts-packaging": "^2.0.6",
5353
"@stryker-mutator/core": "^8.2.6",
54-
"@stryker-mutator/jest-runner": "^8.2.6",
54+
"@stryker-mutator/vitest-runner": "^8.2.6",
5555
"@types/busboy": "^1.5.3",
56-
"@types/jest": "^29.5.12",
5756
"@types/node": "^20.11.30",
5857
"@types/qs": "^6.9.14",
58+
"@vitest/coverage-v8": "^1.6.0",
5959
"form-data": "^4.0.0",
60-
"jest": "^29.7.0",
61-
"prettier": "^3.2.5",
62-
"prettier-2": "npm:prettier@^2.8.8",
60+
"prettier": "^3.3.2",
6361
"qs": "^6.12.0",
64-
"ts-jest": "^29.1.2",
65-
"typescript": "^5.4.3"
62+
"typescript": "^5.4.3",
63+
"vitest": "^1.6.0"
6664
},
6765
"publishConfig": {
6866
"access": "public"

src/multipart-middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createWriteStream, mkdirSync } from 'fs';
33
import type { IncomingHttpHeaders } from 'http';
44
import { tmpdir } from 'os';
55
import { PassThrough } from 'stream';
6-
import * as busboy from 'busboy';
6+
import busboy from 'busboy';
77
import type { Middleware } from '@chubbyts/chubbyts-http-types/dist/middleware';
88
import type { ServerRequest, Response } from '@chubbyts/chubbyts-http-types/dist/message';
99
import type { Handler } from '@chubbyts/chubbyts-http-types/dist/handler';

stryker.conf.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
3-
"testRunner": "jest",
4-
"concurrency": 1,
3+
"testRunner": "vitest",
4+
"vitest": {
5+
"configFile": "vitest.config.ts"
6+
},
7+
"coverageAnalysis": "off",
58
"reporters": [
69
"clear-text",
710
"progress",

tests/multipart-middleware.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { PassThrough } from 'stream';
33
import { createReadStream, readFileSync, promises as fs } from 'fs';
44
import { tmpdir } from 'os';
55
import { createHash } from 'crypto';
6-
import { describe, expect, test } from '@jest/globals';
6+
import { describe, expect, test } from 'vitest';
77
import { useFunctionMock } from '@chubbyts/chubbyts-function-mock/dist/function-mock';
88
import type { Handler } from '@chubbyts/chubbyts-http-types/dist/handler';
99
import type { Response, ServerRequest } from '@chubbyts/chubbyts-http-types/dist/message';
10-
import * as FormData from 'form-data';
1110
import { parse } from 'qs';
11+
import FormData from 'form-data';
1212
import { createMultipartMiddleware } from '../src/multipart-middleware';
1313

1414
const redImagePath = process.cwd() + '/tests/resources/red.png';

tsconfig.json

-1
This file was deleted.

tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./node_modules/@chubbyts/chubbyts-packaging/tsconfig.json",
3+
"compilerOptions": {
4+
"esModuleInterop": true,
5+
},
6+
"include": [
7+
"src"
8+
]
9+
}

vitest.config.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
import { defineConfig } from 'vitest/config';
3+
4+
export default defineConfig({
5+
test: {
6+
globals: true,
7+
environment: 'node',
8+
include: ['tests/**/*.test.*'],
9+
coverage: {
10+
all: true,
11+
clean: true,
12+
reporter: ['clover', ['html', { subdir: 'html' }], 'json', 'lcovonly', 'text'],
13+
provider: 'v8',
14+
thresholds: {
15+
lines: 100,
16+
},
17+
include: ['src/**/*.ts'],
18+
},
19+
},
20+
});

0 commit comments

Comments
 (0)