Skip to content

Commit

Permalink
test: improve axios errors in test
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Oct 4, 2024
1 parent 4d6ccfe commit 8afa887
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/node/third-party/axios-upload.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ it('responds with a mocked response to an upload request', async () => {
const file = new Blob(['Hello', 'world'], { type: 'text/plain' })
formData.set('file', file, 'doc.txt')

await expect(request.post('/upload', formData)).resolves.toMatchObject({
data: {
message: 'Successfully uploaded "doc.txt"!',
content: 'Helloworld',
},
const response = await request.post('/upload', formData).catch((error) => {
throw error.response.data
})

expect(response.data).toEqual({
message: 'Successfully uploaded "doc.txt"!',
content: 'Helloworld',
})

expect(onUploadProgress.mock.calls.length).toBeGreaterThan(0)
Expand Down

0 comments on commit 8afa887

Please sign in to comment.