Skip to content

Commit

Permalink
feat: drop node-fetch and vitest dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
FossPrime committed Sep 27, 2023
1 parent a1b3584 commit 24febae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev:client": "VITE_SSG=off vite",
"dev:server": "npx tsx watch --clear-screen=false server/index.ts",
"preview": "vite preview",
"test:server": "npx tsc --noEmit && npx vitest run",
"test:server": "npx tsc --noEmit && node --loader tsx --test test/**/*.ts",
"test:client": "npx tsc --noEmit",
"build": "tsc && vite build --outDir dist/client",
"bundle:client": "tsc --declaration --outDir dist/server src/services/*/*.schema.ts",
Expand All @@ -25,7 +25,7 @@
"directory": "starter"
},
"engines": {
"node": ">= 16"
"node": ">= 16.20"
},
"dependencies": {
"@feathersjs/authentication": "5.0.5",
Expand All @@ -46,15 +46,16 @@
"@types/cors": "^2.8.12",
"@types/jsonwebtoken": "^8.5.8",
"feathers-vite": "~1.2.7",
"node-fetch": "^3.2.9",
"typescript": "^5.1.3",
"vite": "4.2.0"
"vite": "4.2.0",
"tsx": "^3.13.0"
},
"stackblitz": {
"installDependencies": false,
"startCommand": "npm run dev",
"env": {
"npm_config_yes": "true"
"npm_config_yes": "true",
"NODE_OPTIONS": "--no-warnings --experimental-fetch"
}
},
"prettier": {
Expand Down
48 changes: 23 additions & 25 deletions test/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { assert, describe, it, beforeEach, afterEach } from 'vitest'
import { Server } from 'http'
import fetch from 'node-fetch'
import { URL } from 'node:url'
import assert from 'node:assert'
import {describe, it, beforeEach, afterEach} from 'node:test'
import {Server} from 'http'
import {URL} from 'node:url'

import { main } from '../src/app.js'
import {main} from '../src/app.js'

const port = '' + 8998
const port = '' + 9000
const getUrl = (pathname?: string) => {
const url = new URL('http://localhost')
url.hostname = 'localhost'
Expand All @@ -25,8 +25,8 @@ describe('Feathers application tests', () => {

afterEach(() => {
console.log('RUNNING AFTER EACH')
return new Promise((resolve, reject) => {
server.close((e) => (e ? reject(e) : resolve()))
return new Promise<void>((resolve, reject) => {
server.close(e => (e ? reject(e) : resolve()))
})
})

Expand All @@ -37,25 +37,23 @@ describe('Feathers application tests', () => {
assert.ok(body.indexOf('<html lang="en">') !== -1)
})

describe('404', function () {
it('shows a 404 HTML page', async () => {
const url = getUrl('path/to/nowhere')
const response = await fetch(url, {
headers: {
Accept: 'text/html'
}
})

assert.equal(response.status, 404)
// assert.ok((await response.text()).indexOf('<html>') !== -1)
it('shows a 404 HTML page', async () => {
const url = getUrl('path/to/nowhere')
const response = await fetch(url, {
headers: {
Accept: 'text/html'
}
})

it('shows a 404 JSON error without stack trace', async () => {
const response = await fetch(getUrl('path/to/nowhere'))
assert.equal(response.status, 404)
// assert.ok((await response.text()).indexOf('<html>') !== -1)
})

assert.equal(response.status, 404)
assert.equal(response.statusText, 'Not Found')
assert.ok(response.url.indexOf('/path/to/nowhere') !== -1)
})
it('shows a 404 JSON error without stack trace', async () => {
const response = await fetch(getUrl('path/to/nowhere'))

assert.equal(response.status, 404)
assert.equal(response.statusText, 'Not Found')
assert.ok(response.url.indexOf('/path/to/nowhere') !== -1)
})
})

0 comments on commit 24febae

Please sign in to comment.