Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: fix unhandled rejections
  • Loading branch information
fratzinger committed Mar 26, 2024
commit 6daf303903b2c5e2003a843e5091451fbb567267
2 changes: 1 addition & 1 deletion packages/authentication-client/test/integration/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default (
assert.ok(result!.accessToken)
assert.ok(result!.user)

assert.rejects(() => client.service('dummy').find(), {
await assert.rejects(() => client.service('dummy').find(), {
name: 'NotAuthenticated',
code: 401,
message: 'Not authenticated'
Expand Down
22 changes: 9 additions & 13 deletions packages/authentication-client/test/integration/express.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios'
import { Server } from 'http'
import { feathers, Application as FeathersApplication } from '@feathersjs/feathers'
import * as express from '@feathersjs/express'
import rest from '@feathersjs/rest-client'
Expand All @@ -10,21 +9,18 @@ import commonTests from './commons'
import getPort from 'get-port'

describe('@feathersjs/authentication-client Express integration', async () => {
let app: express.Application
let server: Server
const port = await getPort()

beforeAll(async () => {
const restApp = express
.default(feathers())
.use(express.json())
.configure(express.rest())
.use(express.parseAuthentication())
app = getApp(restApp as unknown as FeathersApplication) as express.Application
app.use(express.errorHandler())
const restApp = express
.default(feathers())
.use(express.json())
.configure(express.rest())
.use(express.parseAuthentication())

server = await app.listen(port)
})
const app = getApp(restApp as unknown as FeathersApplication) as express.Application
app.use(express.errorHandler())

const server = await app.listen(port)

afterAll(() => new Promise<void>((resolve) => server.close(() => resolve())))

Expand Down
19 changes: 8 additions & 11 deletions packages/authentication-client/test/integration/socketio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import authClient from '../../src'
import getApp from './fixture'
import commonTests from './commons'
import { AuthenticationResult } from '@feathersjs/authentication/lib'
import getPort from 'get-port'

describe('@feathersjs/authentication-client Socket.io integration', () => {
let app: Application

beforeAll(async () => {
app = getApp(feathers().configure(socketio()))

await app.listen(9777)
})
describe('@feathersjs/authentication-client Socket.io integration', async () => {
const app = getApp(feathers().configure(socketio()))
const port = await getPort()
await app.listen(port)

afterAll(() => new Promise<void>((resolve) => app.io.close(() => resolve())))

Expand All @@ -30,7 +27,7 @@ describe('@feathersjs/authentication-client Socket.io integration', () => {
...user
})

const socket = io('http://localhost:9777', {
const socket = io(`http://localhost:${port}`, {
transports: ['websocket'],
transportOptions: {
websocket: {
Expand All @@ -55,7 +52,7 @@ describe('@feathersjs/authentication-client Socket.io integration', () => {

it('reconnects after socket disconnection', async () => {
const user = { email: 'disconnecttest@example.com', password: 'alsosecret' }
const socket = io('http://localhost:9777', {
const socket = io(`http://localhost:${port}`, {
timeout: 500,
reconnection: true,
reconnectionDelay: 100
Expand Down Expand Up @@ -86,7 +83,7 @@ describe('@feathersjs/authentication-client Socket.io integration', () => {
() => app,
() => {
return feathers()
.configure(socketioClient(io('http://localhost:9777')))
.configure(socketioClient(io(`http://localhost:${port}`)))
.configure(authClient())
},
{
Expand Down
6 changes: 3 additions & 3 deletions packages/schema/test/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ describe('@feathersjs/schema/hooks', () => {
})
})

it('ran resolvers in sequence', async () => {
it('ran resolvers in sequence', () => {
assert.strictEqual(user.name, 'hello (hello@feathersjs.com)')
})

it('validates data', async () => {
assert.rejects(() => app.service('users').create({ password: 'failing' } as any), {
await assert.rejects(() => app.service('users').create({ password: 'failing' } as any), {
name: 'BadRequest'
})
})
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('@feathersjs/schema/hooks', () => {
user
})

assert.rejects(
await assert.rejects(
() =>
app.service('messages').find({
query: {
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/test/resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('@feathersjs/schema/resolver', () => {
}
})

assert.rejects(
await assert.rejects(
() =>
dummyResolver.resolve(
{
Expand Down