Skip to content

Commit 94e0b6e

Browse files
author
v1rtl
committed
tooling: move from jest to vitest
1 parent 8307350 commit 94e0b6e

31 files changed

Lines changed: 696 additions & 2386 deletions

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ jobs:
6565
uses: coverallsapp/github-action@master
6666
with:
6767
github-token: ${{ secrets.GITHUB_TOKEN }}
68+
path-to-lcov: ./coverage.lcov

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ examples/*/.env
88
.clinic
99
examples/aws/.build
1010
.pnpm-debug.log*
11-
*.log
11+
*.log
12+
coverage.lcov

jest.config.mjs

Lines changed: 0 additions & 22 deletions
This file was deleted.

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,30 @@
1212
},
1313
"devDependencies": {
1414
"@changesets/cli": "2.22.0",
15-
"@commitlint/cli": "16.2.3",
15+
"@commitlint/cli": "17.0.2",
1616
"@commitlint/config-conventional": "16.2.1",
17-
"@jest/globals": "27.5.1",
1817
"@rollup/plugin-typescript": "~8.3.1",
19-
"@types/jest": "27.4.1",
2018
"@types/node": "17.0.23",
2119
"@typescript-eslint/eslint-plugin": "5.18.0",
2220
"@typescript-eslint/parser": "5.18.0",
21+
"c8": "^7.11.3",
2322
"colorette": "2.0.16",
2423
"dirname-filename-esm": "1.1.1",
25-
"enhanced-resolve": "5.9.2",
2624
"eslint": "8.13.0",
2725
"eslint-config-prettier": "8.5.0",
2826
"eslint-plugin-prettier": "4.0.0",
2927
"eta": "1.12.3",
3028
"header-range-parser": "^1.1.3",
31-
"husky": "7.0.4",
32-
"jest": "27.5.1",
29+
"husky": "8.0.1",
3330
"jsonwebtoken": "8.5.1",
3431
"prettier": "2.6.2",
3532
"regexparam": "2.0.0",
3633
"rollup": "~2.70.1",
3734
"supertest-fetch": "1.5.0",
38-
"ts-jest": "27.1.4",
39-
"tslib": "2.3.1",
40-
"typescript": "~4.6.3"
35+
"tslib": "2.4.0",
36+
"typescript": "~4.7.3",
37+
"vite": "^2.9.9",
38+
"vitest": "^0.14.0"
4139
},
4240
"scripts": {
4341
"prerelease": "pnpm lint && pnpm build && pnpm test",
@@ -46,7 +44,10 @@
4644
"rm-changelogs": "rm -rf packages/*/CHANGELOG.md",
4745
"chgset": "pnpm chgset:run && pnpm chgset:version && pnpm rm-changelogs",
4846
"release": "changeset publish",
49-
"test": "NODE_OPTIONS=--experimental-vm-modules TESTING=true jest",
47+
"test:dev": "TESTING=true vitest",
48+
"test:report": "c8 report --reporter=text-lcov > coverage.lcov",
49+
"test:coverage": "CI=true TESTING=true vitest --coverage",
50+
"test": "pnpm test:coverage && pnpm test:report",
5051
"lint": "eslint . --ext=js,mjs,ts,cjs",
5152
"format": "prettier --check \"./**/*.{ts,js,mjs,cjs,md}\"",
5253
"format:fix": "prettier --write \"./**/*.{ts,js,mjs,cjs,md}\"",

packages/app/src/app.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type AppSettings = Partial<{
3838
bindAppToReqRes: boolean
3939
xPoweredBy: string | boolean
4040
enableReqRoute: boolean
41+
views: string
4142
}>
4243

4344
/**
@@ -105,7 +106,7 @@ export class App<
105106
super()
106107
this.onError = options?.onError || onErrorHandler
107108
this.noMatchHandler = options?.noMatchHandler || this.onError.bind(null, { code: 404 })
108-
this.settings = options.settings || { xPoweredBy: true }
109+
this.settings = options.settings || { xPoweredBy: true, views: process.cwd() }
109110
this.applyExtensions = options?.applyExtensions
110111
this.attach = (req, res) => setImmediate(this.handler.bind(this, req, res, undefined), req, res)
111112
}
@@ -153,7 +154,7 @@ export class App<
153154
cb: (err: unknown, html: unknown) => void,
154155
options: TemplateEngineOptions<RenderOptions> = {}
155156
): this {
156-
options.viewsFolder = options.viewsFolder || `${process.cwd()}/views`
157+
options.viewsFolder = options.viewsFolder || this.settings.views || `${process.cwd()}/views`
157158
options.ext = options.ext || file.slice(file.lastIndexOf('.') + 1) || 'ejs'
158159

159160
options._locals = options._locals || {}

packages/rate-limit/src/rate-limit.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ const defaultOptions: RateLimitOptions = {
4242
onLimitReached: () => {}
4343
}
4444

45-
export function rateLimit(
46-
options?: Partial<RateLimitOptions>
47-
): (req: RequestWithRateLimit, res: Response, next: (err?: any) => void) => Promise<void> {
45+
export function rateLimit(options?: Partial<RateLimitOptions>): ((
46+
req: RequestWithRateLimit,
47+
res: Response,
48+
next: (err?: any) => void
49+
) => Promise<void>) & {
50+
resetKey: (key: string) => void
51+
} {
4852
const {
4953
shouldSkip,
5054
keyGenerator,

0 commit comments

Comments
 (0)