forwardemail / forwardemail/supertest

Adding complex object to request().field() method

Open
#842 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
14.4k
Forks
782
PR merge metrics
No merged PRs in 30d

Description

## Describe the bug

**Node.js version:** 18.18.2

**OS version:** macOS Sonoma 14.4

**Description:**

When adding complex object to field() method, the documentation says to use it like this. #759

.field('complex_object', '{"attribute": "value"}', {contentType: 'application/json'})

With this solution, I got an error.

Expected 1-2 arguments, but got 3.ts(2554)

@types/supertest 6.0.2
supertest 7.0.0
typescript 5.4.5

## Actual behavior

```
await request(app)
.post('/test')
.field('myObject', JSON.stringify({ key1: 'key1', key2: 'key2' }), { contentType: 'application/json' })
.attach('attachments', path.join(__dirname, 'image.png'))
.expect(200)
```

## Expected behavior

Test success without an error.

## Code to reproduce

## Checklist

- [x] I have searched through GitHub issues for similar issues.
- [x] I have completely read through the README and documentation.
- [ ] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.