Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

test-listen

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test-listen - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

yarn.lock

4

index.js

@@ -1,2 +0,2 @@

module.exports = srv => new Promise((resolve, reject) => {
module.exports = (srv, hostname = 'localhost') => new Promise((resolve, reject) => {
srv.on('error', reject)

@@ -6,4 +6,4 @@

const {port} = srv.address()
resolve(`http://localhost:${port}`)
resolve(`http://${hostname}:${port}`)
})
})
{
"name": "test-listen",
"version": "1.0.2",
"version": "1.1.0",
"description": "Produce URLs to test HTTP servers with ephemeral ports",

@@ -5,0 +5,0 @@ "main": "./index",

@@ -18,2 +18,5 @@ # test-listen

The second parameter can optionally be a hostname to return in the URL
instead of `localhost`.
Useful for running HTTP server testsuites:

@@ -20,0 +23,0 @@

@@ -9,2 +9,3 @@ // eslint-disable-next-line ava/no-ignored-test-files

const srv2 = http.createServer((req, res) => res.end('2'))
const srv3 = http.createServer((req, res) => res.end('3'))

@@ -22,2 +23,8 @@ test('it works', async t => {

t.deepEqual('2', data2)
const url3 = await listen(srv3, '127.0.0.1')
t.true(url3 !== url)
t.true(/http:\/\/127.0.0.1:\d+/.test(url3))
const data3 = await request(url3)
t.deepEqual('3', data3)
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc