You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an econnrest error when attempting to upload a file in my Jest test using superagent. The error occurs when the attach() method is called to attach the file to the request.
Node.js version: 20.17
OS version: Windows 11 Pro
Code to reproduce
test('should throw not found error when the question does not allow any files', async () => {
let question = getQuestion()
question.allowFile = false
question.isFileRequired = false
const mpg = pg as unknown as jest.Mock
mpg.mockReturnValueOnce(mock(question))
const res1 = await request({
rolesId: UserRole.ADMIN,
})
.post('/questionnairee/question/1/answer/file')
.attach('file', '__mocks__/data/files/image_1.png') //This is where the issue is being produced
.expect(404)
expect(ErrorResSchema.safeParse(res1.body).success).toBeTruthy()
question = getQuestion()
question.allowFile = false
question.isFileRequired = true
mpg.mockReturnValueOnce(mock(question))
const res2 = await request({
rolesId: UserRole.ADMIN,
})
.post('/questionnairee/question/1/answer/file')
.attach('file', '__mocks__/data/files/image_1.png')
.expect(404)
expect(ErrorResSchema.safeParse(res2.body).success).toBeTruthy()
})
Checklist
[v] I have searched through GitHub issues for similar issues.
[v] I have completely read through the README and documentation.
[v] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm encountering an econnrest error when attempting to upload a file in my Jest test using superagent. The error occurs when the attach() method is called to attach the file to the request.
Node.js version: 20.17
OS version: Windows 11 Pro
Code to reproduce
Checklist
The text was updated successfully, but these errors were encountered: