Skip to content

Commit

Permalink
test: remove undocumented and undefined usage of req.reject (#186)
Browse files Browse the repository at this point in the history
fixes issue mentioned in #185

(closes #185)
  • Loading branch information
schwma authored Oct 9, 2024
1 parent 53a8a80 commit a204b12
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
1 change: 0 additions & 1 deletion test/resources/error-handling/srv/custom-handler-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ module.exports = srv => {

if (id === 1) req.reject(400, message, args)
if (id === 2) req.reject(code, message, args)
req.reject(message)
}
})
}
33 changes: 2 additions & 31 deletions test/tests/error-handling-dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,15 @@ describe('graphql - error handling in development', () => {
message: 'Some Custom Error Message 1',
numericSeverity: 4,
status: 418,
target: 'some_field',
target: 'some_field'
// stack: expect.any(String) // doesn't work with Node 22
},
{
code: 'Some-Custom-Code2',
message: 'Some Custom Error Message 2',
numericSeverity: 4,
status: 500,
target: 'some_field',
target: 'some_field'
// stack: expect.any(String) // doesn't work with Node 22
}
]
Expand Down Expand Up @@ -452,34 +452,5 @@ describe('graphql - error handling in development', () => {
expect(response.data).toMatchObject({ errors })
expect(response.data.errors[0].extensions.stacktrace).not.toHaveLength(0) // Stacktrace exists and is not empty
})

test('req.reject with custom code', async () => {
const query = gql`
mutation {
CustomHandlerErrorsService {
Orders {
create(input: { id: 3, quantity: 20, stock: 10 }) {
id
quantity
stock
}
}
}
}
`
const errors = [
{
message: 'The order of NULL books exceeds the stock by NULL',
extensions: {
code: '500',
numericSeverity: 4,
stacktrace: expect.any(Array)
}
}
]
const response = await POST('/graphql', { query })
expect(response.data).toMatchObject({ errors })
expect(response.data.errors[0].extensions.stacktrace).not.toHaveLength(0) // Stacktrace exists and is not empty
})
})
})

0 comments on commit a204b12

Please sign in to comment.