Giter Site home page Giter Site logo

Stop test server about vhost HOT 2 CLOSED

expressjs avatar expressjs commented on May 8, 2024
Stop test server

from vhost.

Comments (2)

guimard avatar guimard commented on May 8, 2024

Update for mocha 7:

--- a/test/test.js
+++ b/test/test.js
@@ -20,6 +20,7 @@
     .get('/')
     .set('Host', 'tobi.com')
     .expect(200, 'tobi', done)
+    closeApp(app)
   })
 
   it('should ignore port in Host', function(done){
@@ -31,6 +32,7 @@
     .get('/')
     .set('Host', 'tobi.com:8080')
     .expect(200, 'tobi', done)
+    closeApp(app)
   })
 
   it('should support IPv6 literal in Host', function(done){
@@ -42,6 +44,7 @@
     .get('/')
     .set('Host', '[::1]:8080')
     .expect(200, 'loopback', done)
+    closeApp(app)
   })
 
   it('should 404 unless matched', function(done){
@@ -59,6 +62,7 @@
     .get('/')
     .set('Host', 'ferrets.com')
     .expect(404, done)
+    closeApp(app)
   })
 
   it('should 404 without Host header', function(done){
@@ -76,6 +80,7 @@
     .get('/')
     .unset('Host')
     .expect(404, done)
+    closeApp(app)
   })
 
   describe('arguments', function(){
@@ -118,6 +123,7 @@
       .get('/')
       .set('Host', 'loki.ferrets.com')
       .expect(200, 'wildcard!', done)
+      closeApp(app)
     })
 
     it('should restrict wildcards to single part', function(done){
@@ -129,6 +135,7 @@
       .get('/')
       .set('Host', 'foo.loki.ferrets.com')
       .expect(404, done)
+      closeApp(app)
     })
 
     it('should treat dot as a dot', function(done){
@@ -140,6 +147,7 @@
       .get('/')
       .set('Host', 'aXb.com')
       .expect(404, done)
+      closeApp(app)
     })
 
     it('should match entire string', function(done){
@@ -151,6 +159,7 @@
       .get('/')
       .set('Host', 'foo.com')
       .expect(404, done)
+      closeApp(app)
     })
 
     it('should populate req.vhost', function(done){
@@ -164,6 +173,7 @@
       .get('/')
       .set('Host', 'user-bob.foo.com:8080')
       .expect(200, '[["0","bob"],["1","foo"],["host","user-bob.foo.com:8080"],["hostname","user-bob.foo.com"],["length",2]]', done)
+      closeApp(app)
     })
   })
 
@@ -177,6 +187,7 @@
       .get('/')
       .set('Host', 'toki.com')
       .expect(200, 'tobi', done)
+      closeApp(app)
     })
 
     it('should match entire hostname', function(done){
@@ -194,6 +205,7 @@
       .get('/')
       .set('Host', 'loki.tobi.com')
       .expect(404, done)
+      closeApp(app)
     })
 
     it('should populate req.vhost', function(done){
@@ -207,10 +219,18 @@
       .get('/')
       .set('Host', 'user-bob.foo.com:8080')
       .expect(200, '[["0","bob"],["1","foo"],["host","user-bob.foo.com:8080"],["hostname","user-bob.foo.com"],["length",2]]', done)
+      closeApp(app)
     })
   })
 })
 
+function closeApp(app) {
+  var close = function() {
+    app.close()
+  }
+  setTimeout(close,2000)
+}
+
 function createServer(hostname, server) {
   var vhosts = !Array.isArray(hostname)
     ? [vhost(hostname, server)]

from vhost.

dougwilson avatar dougwilson commented on May 8, 2024

Hi, thanks for the report! I just ran the test suite, including updating to mocha@7 and the test suite ran without issue. The supertest library, when given a reference to an app where app is not already listening, will start the server and automatically close it after the tests.

If you believe there is an issue, you're always welcome to open a pull request 👍 but I was not able to reproduce any issue with the information provided here.

from vhost.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.