Skip to content

Commit 5dd59f1

Browse files
committed
refactor!: update repo
1 parent 4e053e6 commit 5dd59f1

15 files changed

Lines changed: 1382 additions & 2739 deletions

.github/workflows/ci.yml

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,16 @@ on:
1010

1111
jobs:
1212
ci:
13-
runs-on: ${{ matrix.os }}
14-
15-
strategy:
16-
matrix:
17-
os: [ubuntu-latest]
18-
node: [14]
13+
runs-on: ubuntu-latest
1914

2015
steps:
21-
- uses: actions/setup-node@v1
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-node@v2
2218
with:
23-
node-version: ${{ matrix.node }}
24-
25-
- name: checkout
26-
uses: actions/checkout@master
27-
28-
- name: cache node_modules
29-
uses: actions/cache@v1
30-
with:
31-
path: node_modules
32-
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
33-
34-
- name: Install dependencies
35-
if: steps.cache.outputs.cache-hit != 'true'
36-
run: yarn
37-
38-
- name: Lint
39-
run: yarn lint
40-
41-
- name: Build
42-
run: yarn build
43-
44-
- name: Test
45-
run: yarn jest
46-
47-
- name: Coverage
48-
uses: codecov/codecov-action@v1
19+
node-version: '16'
20+
cache: yarn
21+
- run: yarn install
22+
- run: yarn lint
23+
- run: yarn build
24+
- run: yarn test --coverage
25+
- uses: codecov/codecov-action@v2

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,38 @@
1818
"dist"
1919
],
2020
"scripts": {
21-
"build": "siroc build",
22-
"dev": "jiti test/playground",
23-
"lint": "eslint --ext ts .",
24-
"profile": "0x -o -D .profile -P 'autocannon -c 100 -p 10 -d 40 http://localhost:$PORT' ./hello.js",
25-
"release": "yarn test && yarn build && standard-version && npm publish && git push --follow-tags",
26-
"test": "yarn lint && jest"
21+
"build": "unbuild",
22+
"dev": "jiti ./playground/index.ts",
23+
"lint": "eslint --ext ts,mjs,cjs .",
24+
"profile": "0x -o -D .profile -P 'autocannon -c 100 -p 10 -d 40 http://localhost:$PORT' ./playground/server.cjs",
25+
"release": "yarn lint && yarn test && yarn build && standard-version && npm publish && git push --follow-tags",
26+
"test": "vitest run"
27+
},
28+
"dependencies": {
29+
"cookie": "^0.4.2",
30+
"destr": "^1.1.0",
31+
"ufo": "^0.7.11"
2732
},
2833
"devDependencies": {
2934
"0x": "latest",
3035
"@nuxtjs/eslint-config-typescript": "latest",
3136
"@types/cookie": "latest",
3237
"@types/express": "latest",
33-
"@types/jest": "latest",
3438
"@types/node": "latest",
3539
"@types/supertest": "latest",
3640
"autocannon": "latest",
41+
"c8": "latest",
3742
"connect": "latest",
3843
"cookie-es": "latest",
39-
"destr": "latest",
4044
"eslint": "latest",
4145
"express": "latest",
4246
"get-port": "^5.0.0",
43-
"jest": "latest",
4447
"jiti": "latest",
4548
"listhen": "latest",
46-
"siroc": "latest",
4749
"standard-version": "latest",
4850
"supertest": "latest",
49-
"ts-jest": "latest",
5051
"typescript": "latest",
51-
"ufo": "latest"
52+
"unbuild": "latest",
53+
"vitest": "latest"
5254
}
5355
}
File renamed without changes.

hello.js renamed to playground/server.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const { createServer } = require('http')
4-
const { createApp } = require('./dist')
4+
const { createApp } = require('..')
55

66
const app = createApp()
77

test/app.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import supertest, { SuperTest, Test } from 'supertest'
2+
import { describe, it, expect, beforeEach } from 'vitest'
23
import { createApp, App } from '../src'
34

45
describe('app', () => {

test/basic.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import { describe, it, expect } from 'vitest'
12
import { promisifyHandle } from '../src'
3+
24
// import { sendReq } from './utils'
35
const sendReq = (_: any) => {}
46

57
describe.skip('promisifyHandle', () => {
6-
test('handles exception', async () => {
8+
it('handles exception', async () => {
79
const h = promisifyHandle(() => { throw new Error('oops') })
810
await expect(sendReq(h)).rejects.toThrow('oops')
911
})
1012

11-
test('handles exception (promise)', async () => {
13+
it('handles exception (promise)', async () => {
1214
const h = promisifyHandle(() => { return Promise.reject(new Error('oops')) })
1315
await expect(sendReq(h)).rejects.toThrow('oops')
1416
})

test/body.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import supertest, { SuperTest, Test } from 'supertest'
2+
import { describe, it, expect, beforeEach } from 'vitest'
23
import { createApp, App, useBody, useRawBody } from '../src'
34

45
describe('', () => {

test/cookie.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import supertest, { SuperTest, Test } from 'supertest'
2+
import { describe, it, expect, beforeEach } from 'vitest'
23
import { createApp, App } from '../src'
34
import { setCookie, useCookie, useCookies } from '../src/utils/cookie'
45

test/e2e.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Server } from 'http'
22
import supertest, { SuperTest, Test } from 'supertest'
33
import getPort from 'get-port'
4+
import { describe, it, expect, beforeEach, afterEach, fn } from 'vitest'
45

56
import { createApp, App } from '../src'
67

7-
; (global.console.error as any) = jest.fn()
8+
; (global.console.error as any) = fn()
89

910
describe('server', () => {
1011
let app: App

test/error.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import supertest, { SuperTest, Test } from 'supertest'
2+
import { describe, it, expect, beforeEach, fn } from 'vitest'
23
import { createApp, App, createError } from '../src'
34

4-
; (global.console.error as any) = jest.fn()
5+
const consoleMock = (global.console.error as any) = fn()
56

67
describe('error', () => {
78
let app: App
@@ -47,7 +48,7 @@ describe('error', () => {
4748
})
4849

4950
it('can send runtime error', async () => {
50-
jest.clearAllMocks()
51+
consoleMock.mockReset()
5152

5253
app.use('/', () => {
5354
throw createError({

0 commit comments

Comments
 (0)