caolan / caolan/forms

obj instanceof http.IncomingMessage hard to create tests for

Open
#160 2 comments 0 reactions 1 assignee Claimed by @ljharb View on GitHub
Feature Requests Needs More Info
Dominant language
JavaScript
Stars
1k
Forks
161
PR merge metrics
No merged PRs in 30d

Description

https://github.com/caolan/forms/blob/fbb4e5dc6ff93a6e8d89480aff7e278f87403915/lib/forms.js#L71
} else if (obj instanceof http.IncomingMessage) {

that line requires that you really have an instanceof http.IncomingMessage which is not really easy to create in a mock, and then randomly the code runs differently, even though you are pass something that looks very very similar to a request ;)

maybe replace with something like:
} else if (obj.body && obj.method && (obj.method === 'POST' || obj.method === 'PUT')) {

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.