Skip to content

Commit

Permalink
test: Method property on requests
Browse files Browse the repository at this point in the history
Add a testcase to ensure mocked requests have the 'method' property defined.
  • Loading branch information
mrijke committed May 20, 2019
1 parent 3c8a26d commit f41ffec
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_request_overrider.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,23 @@ test('should throw expected error when creating request with missing options', t
})
t.end()
})

// https://github.com/nock/nock/issues/1558
test("mocked requests have 'method' property", t => {
nock('http://example.test')
.get('/somepath')
.reply(200, {})

const req = http.request({
host: 'example.test',
path: '/somepath',
method: 'GET',
port: 80,
})
t.equal(req.method, 'GET')
req.on('response', function(res) {
t.equal(res.req.method, 'GET')
t.end()
})
req.end()
})

0 comments on commit f41ffec

Please sign in to comment.