Skip to content

Commit

Permalink
Fixed #33 (error handler was registered too early in tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
claustres committed Sep 10, 2019
1 parent 0020419 commit 0bb71b9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ describe('feathers-distributed', () => {
app.configure(authentication({ secret: '1234' }))
const strategies = ['jwt']
app.configure(jwt())
// See https://github.com/kalisio/feathers-distributed/issues/3
// app.use(express.notFound());
app.use(express.errorHandler())
if (index === gateway) {
strategies.push('local')
app.configure(local())
Expand Down Expand Up @@ -165,6 +162,9 @@ describe('feathers-distributed', () => {
// For remote services we have to wait they are registered
promises.push(waitForService(apps, services, i))
}
// See https://github.com/kalisio/feathers-distributed/issues/3
// apps[i].use(express.notFound());
apps[i].use(express.errorHandler())
}
await Promise.all(promises)
promises = []
Expand Down Expand Up @@ -353,6 +353,7 @@ describe('feathers-distributed', () => {
try {
await socketClientServices[gateway].find({})
} catch (err) {
// As internal service call should not use express handler
expect(err.code).to.equal(401)
}
})
Expand All @@ -362,6 +363,7 @@ describe('feathers-distributed', () => {
try {
await request.get(url)
} catch (err) {
// As external service call should use express handler
expect(err.response.text.includes('NotAuthenticated')).beTrue()
expect(err.status).to.equal(401)
}
Expand All @@ -371,6 +373,7 @@ describe('feathers-distributed', () => {
try {
await socketClientServices[service1].find({})
} catch (err) {
// As internal service call should not use express handler
expect(err.code).to.equal(401)
}
})
Expand All @@ -380,6 +383,7 @@ describe('feathers-distributed', () => {
try {
await request.get(url)
} catch (err) {
// As external service call should use express handler
expect(err.response.text.includes('NotAuthenticated')).beTrue()
expect(err.status).to.equal(401)
}
Expand Down

0 comments on commit 0bb71b9

Please sign in to comment.